CharlesMcquade/p12_group
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Due date: 11/23/2014 @ 11:59pm
Please don't forget to answer the questions in REPORT.txt
Assignment:
~~~~~~~~~~~
Implement a simple shell that:
- Displays a prompt on the console "shell> "
- Reads a line from the console
- Trims spaces by:
* removing leading and trailing spaces
* reducing consecutive spaces to one
- breaks up the line into a number of tokens separated by spaces
- interprets the first token as a program name and the rest of the tokens
as command line arguments
- if the first argument names:
* an ELF file, run the given program and pass the arguments to it
* a file, print the contents of the file and ignore the arguments
* else, print an error message
- blocks until the program terminates then continues to interpret commands
In order to allow arguments to be passed to programs, we need to enhance our
implementation of exec and implement execv (man execv) for more details.
You also need to implement a few commands:
- ls => lists the files in the current directory
- echo => echoes its arguments
- cat => displays the contents of he given files
- shutdown => stops the system
Look for useful functions in user/libc.c
Sample shell session:
~~~~~~~~~~~~~~~~~~~~~
ag@ubuntu:~/cs439h_f14_p11$ qemu-system-x86_64 -nographic --serial mon:stdio -hdc kernel/kernel.img -hdd fat439/user.img
x
What just happened? Who am I? Why am I here?
I am K439, welcome to my world
I have a heap
[] Process tracing enabled
Pit::init freq=1000HZ, divide=1193
Pit::init requested:1000Hz, actual:1000Hz
[] loaded driver for hdd
[] initialized root filesystem
[] Let there be processes
shell> ls
shutdown
shutdown.c
shell.c
shell
ls.c
ls
echo
echo.c
cat.c
cat
f1.txt
f2.txt
panic
shell> f1.txt
This is f1
It contains text
shell> f1.txt f2.txt
This is f1
It contains text
shell> f2.txt
0
11
222
3333
44444
555555
shell> cat f1.txt f2.txt
This is f1
It contains text
0
11
222
3333
44444
555555
shell> gcc
gcc: command not found
shell> cat abc
cat: abc: No such file or directory
shell> shutdown
*** System Shutdown ***
To compile:
~~~~~~~~~~~
make
To run test:
~~~~~~~~~~~~
make clean test
To make the output less noisy:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make -s clean test
test.out contains the output from running the test
test.ok contains the expected output
test.diff contains the difference between the two (using diff)
To run by hand
~~~~~~~~~~~~~~
make
qemu -nographic --serial mon:stdio -hdc kernel/kernel.img -hdd fat439/user.img
To attach with gdb
~~~~~~~~~~~~~~~~~~
It's a good idea to change the -O3 to -O0 in common.mak if you want to debug
with gdb
make
qemu -S -s -nographic --serial mon:stdio -hdc kernel/kernel.img -hdd fat439/user.img
then in another window
> gdb kernel/kernel
(gdb) target remote localhost:1234
(gdb) # define breakpoint, etc
(gdb) cont
Printing to the console:
~~~~~~~~~~~~~~~~~~~~~~~~
You might find Debug::printf(...) and Debug::panic(...) useful. Both are in
kernel/debug.cc
Process::trace(...) is another useful function. It includes information
about the process generating the output
Files to leave alone:
~~~~~~~~~~~~~~~~~~~~~
Makefile
common.mak
kernel/Makefile
user/*
fat439/*