Notes: the file
Files/nachos-3.4.tar.gz
is given by PKU OS course TA. May be differ from other resources. (e.g. directory structure)
- Development Environment
- 32-bit gcc, g++
- docker
- Learn Makefile
- Understand Nachos Makefile structure
- Understanding Nachos code structure
- Read
threads/main.cc
, understand the booting process. - Read
threads/system.cc
andthreads/system.h
, understand the OS and VM component
- Read
Because we compile 32-bit program on 64-bit OS. We need to add some flag in the Makefile
.
- Modify
code/Makefile.common
- add
-m32
after gcc and g++ - add
--32
after as (or change$(AS) -o switch.o swtch.s
to$(AS) --32 -o switch.o swtch.s
)
- add
- (alterative to step 1) Modify
code/Makefile.dep
- change
HOSTCFLAGS
fromHOSTCFLAGS = -Dx86 -DLINUX
toHOSTCFLAGS = -Dx86 -DLINUX -march=athlon64 -O2 -m32
- add
-m32
afterLDFLAGS =
- change
- Also add
-m32
incode/bin/Makefile
If you use 32-bit OS or container you can skip this step
make
This step will modify the following files automatically
filesys/Makefile
network/Makefile
threads/Makefile
userprog/Makefile
vm/Makefile
test/halt
test/matmult
test/shell
test/sort
and generate the following files
bin/coff2noff
test/halt.coff
test/matmult.coff
test/shell.coff
test/sort.coff
filesys/nachos
filesys/swtch.s
network/nachos
network/swtch.s
threads/nachos
threads/swtch.s
userprog/nachos
userprog/swtch.s
vm/nachos
vm/swtch.s
Execute userprog/nachos
(or any nachos
binary in other subdirectory)
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!
Ticks: total 10, idle 0, system 10, user 0
Disk I/O: reads0, writes 0
Console I/O: reads 0, writes 0
Paging: faults 0
Network I/O: packets received 0, sent 0
Cleaning up...
- Compile
coff2noff
- Run
coff2noff/configure
- Modify Makefile and add 32bit flag
- Run
- Modify
code/lib/sysdep.h
- Change
#include "iostream.h"
to#include "iostream" using namespace std;
- Change
- Go to
code/build.linux
- modify Makefile
- add 32bit flag
- remove
-fwritable-strings
form CFLAGS
make depend
make nachos
or justmake
(TODO)- Run
./nachos -u
haven't finish yet
-
code/threads/switch.c > switch.s
switch.s: Assembler messages: switch.s:5: Error: invalid instruction suffix for 'push' ... for 'call' ... for 'pop'
didn't add
--32
to assembler (as) -
Cannot find
-lstdc++
didn't install
g++-multilib
-
code/bin/coff2noff halt.coff halt
File is not a OMAGIC file
This happen because
code/bin/coff2noff
that we've compiled is 64-bit.Program can be check by
$ file filename
. (How to check if my software is 32-bit or 64-bit)didn't add
-m32
tocode/bin/Makefile
-
make (Nachos-4.1 build.linux)
/usr/include/x86_64-linux-gnu/c++/7/32/bits/error_constants.h error: ‘EAFNOSUPPORT’ was not declared in this scope error: ‘EADDRINUSE’ was not declared in this scope ... Makefile:339 recipe for target 'bitmap.o' failed
It seems to be C vs. C++ problem, not sure.
-
Value too large for defined data type (make using docker mount)
- Stackoverflow - cc1plus: error: include: Value too large for defined data type when compiling with g++
- Command find show “Value too large for defined data type”
problem is appear when
- docker -v local_nachos
- make all in code/
- (because of code/test?!)
but if only make in code/threads this won't happen