操作系統作業輔導

CSCI212 assignment3 solution: shell interpreter implementation

 

CSCI212/MCS9212

Assignment 3 (7.5 marks)

<标题>Due 11:59pm Sunday May 17, 2015.

The aim of this assignment is to write a simple shell interpreter demonstrating you knowledge of process

control. In addition to this you will get some experience with file system API’s.

<标题>Task One (4.5 marks)

You first task is to write a simple shell interpreter, which executes commands. You shell interpreter should

<标题>display a $ prompt and wait for user input.

You shell interpreter is to be a little simplistic, all you can do is execute commands. If a command cannot be

found you should display a suitable error message. When executing a command the shell interpreter should

wait until the command terminates. To implement command execution simply use the function call fork()

and exec(). Note that there are many variations on the exec() function call. To block the shell, you

should use the wait() (or similar) function call.

At the end of this step you should be able to do this:

$ ./foobar

./foobar does not exist.

$ ls

QEMU: Adding a System Call

Assignment 3 CMPT-300

QEMU: Adding a System Call

Disclaimer: This assignment is adapted from a project developed by Dr. Jason Nieh at

Columbia University.

Part A:

Setup Your Linux Kernel Building Environment and add dummy

syscall(25%):

The first step is to learn how to create a virtual machine using QEMU and install a

<标题>custom kernel.

Please follow this tutorial:

http://www.sfu.ca/~rws1/cmpt-300/assignments/a3-qemu-tut.pdf

<标题>All files can be downloaded from:

http://www.sfu.ca/~rws1/cmpt-300/assignments/cmpt300-a3.zip

Part B:

Adding an advanced system call(75%):

Write a new system call in Linux. The system call you write should take one argument

<标题>(pointer to a data structure) and return various information for the process identified by

the pid in the data structure. All return information will be put into the data structure. For

the following discussion all relative paths refer to the top of your kernel source

directory linux-2.6.26.5

The prototype for your system call will be:

int prinfo(struc