Skip to content

Latest commit

 

History

History
156 lines (120 loc) · 5.37 KB

DevEnvironment.md

File metadata and controls

156 lines (120 loc) · 5.37 KB

Development Environment

Because NachOS need to be built under 32bit.

Install 32-bit libraries on 64-bit Ubuntu

sudo apt-get install gcc-multilib g++-multilib

Test:

#include <stdio.h>

int main(){
    long z;
    printf("Long int size is %i bytes long!\n", sizeof(z));
    return 0;
}
$ gcc -m32 -o output32 hello.c
$ ./output32
Long int size is 4 bytes long!

$ gcc -m64 -o output64 hello.c
$ ./output64
Long int size is 8 bytes long!

Use 32bit image directly

...

Use Docker with 32bit image

Building

Build the clean version given by TA

bash build_clean_nachos.sh
# the outcome image will be nachos:0.0.1

Build the modified version in this github repository

bash build_modified_nachos.sh
# the outcome image will be nachos:latest and nachos:0.1 (default)

# it can also take an argument of a specific version
./build_modified_nachos.sh 0.1.1

Build only the specific subdirectory (Recommend, especially when you're just dealing with a specific Lab)

# build threads for example (use any subdirectory name under nachos-3.4/code/)
./build_subdir_nachos.sh threads
# the outcome image will be nachos_<subdir>:latest

Running

Running example

# Interactive
$ docker run -it nachos:0.0.1

# Interactive with mount local project
# (Run this in the root of this repository)
$ docker run -it -v $(pwd)/Nachos:/Nachos nachos:latest

# Run a single test
$ docker run nachos:latest nachos/nachos-3.4/code/threads/nachos
*** thread 0 looped 0 times
*** thread 1 looped 0 times
*** thread 0 looped 1 times
*** thread 1 looped 1 times
*** thread 0 looped 2 times
*** thread 1 looped 2 times
*** thread 0 looped 3 times
*** thread 1 looped 3 times
*** thread 0 looped 4 times
*** thread 1 looped 4 times
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!

Ticks: total 130, idle 0, system 130, user 0
Disk I/O: reads 0, writes 0
Console I/O: reads 0, writes 0
Paging: faults 0
Network I/O: packets received 0, sent 0

Cleaning up...

# Other ways to playing around
# Interactive concole test
$ docker run -it nachos nachos/nachos-3.4/code/userprog/nachos -c
# Step by step user program
& docker run -it nachos nachos/nachos-3.4/code/userprog/nachos -s -d a -x nachos/nachos-3.4/code/test/halt

GDB debugging

# Example of debugging threads/nachos built by `./build_subdir_nachos.sh threads`
$ docker run -it nachos_threads gdb nachos/nachos-3.4/code/threads/nachos
(gdb) run -d t -q 1

References

Docker related

Shell script related