辅导案例-COMP 3000

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
Carleton University
School of Computer Science

COMP 3000 (FALL 2020) OPERATING SYSTEMS
ASSIGNMENT 1

Please submit the answers to the following questions via CULearn by 9:59 AM on October 5, 2020. There
are 18 points (weight: 0.25) in 9 questions in total.
Submit your answers as a gzipped tarball "username-comp3000-assign1.tar.gz" (where username is your
MyCarletonOne username).
Unlike tutorials, assignments are graded for the correctness of the answers.
The tarball you submit must contain the following:
1. A plaintext file containing your solutions to all questions, including explanations. Further details are
provided below.
2. A README.txt file listing the contents of your submission as well as any commands the TAs should
use to compile your code (or provide a Makefile). The TAs will only try with available information
(e.g., the default is gcc with no special options).
3. The source code for your modified version of 3000shell. This file should include all required
changes.
4. A diff file showing the modifications, by comparing the submitted file in 3 above and the original:
diff -c 3000shell.c your_modified_3000shell.c > 3000shell.diff. Avoid moving around
or changing existing code (unless necessary) which may be distracting.
You can use this command to create the tarball: tar zcvf username-comp3000-assign1.tar.gz
your_assignment_directory.
No other formats will be accepted. Submitting in another format will likely result in your assignment not being
graded and you receiving no marks for this assignment. In particular, do not submit an MS Word,
OpenOffice, or PDF file as your answers document!
Empty or corrupted tarballs may be given a grade of zero, so please double check your submission by
downloading and extracting it.
Don't forget to include what outside resources you used to complete each of your answers, including other
students, man pages, and web resources. You do not need to list help from the instructor, TA, or information
found in the textbook.
Use of any outside resources verbatim as your answer (like copy-paste or quotation) is not allowed, and will
be treated as unauthorized collaboration (if it’s from another student).
Please do NOT post assignment solutions on Discord or cuLearn forums or it will be penalized.
Questions – part 1 [6]
1. How do you find out whether or prove that a specific dynamic library (use the file name of the
libc.so of your system) has printf() available? [1] Mention the command name you use. [2]
Provide a single-line command that whoever grades this question can execute to easily verify (as
there are various ways to do it), with a brief explanation. There should not be excessive lines of
output to look at.
2. [1] There is a system call vfork(), which does not create a separate address space for the child
process and blocks the parent until the child invokes one of the exec() calls or exits (recall the
2
usage of fork() and exec() in a shell). What do you think is the purpose of vfork(), given that
there is already fork()?
3. [2] Review 3000memview from Tutorial 2. Where does malloc() allocate memory from at different
times (inside or outside the program’s address space) as the allocated amount increases? How do
you know that? (No need to show code)
Questions – part 2 [12]
The following questions will be based on the original 3000shell.c in Tutorial 3:
1. [2] Identify 4 library calls in 3000shell that invoke system calls and explain what the system calls are
used for therein.
2. [1] When you run an interactive program (e.g., nano or top) in the background with “&” in 3000shell,
you may see characters typed lost every so often, or even end up with an unresponsive terminal.
Why? From the source code of run_program(), summarize your speculation in 1-3 sentences.
3. [2] Implement support for standard input redirection, with the operator “<”. For example, in bash, you
can wc -l command in 3000shell.
Note that space following the operator is still not supported in 3000shell (even for standard output
redirection). If you can implement the space support for redirection, you’ll get 4 bonus points
(beyond the 18). Then you can do: wc -l < myfile.txt
4. [3] Implement support for custom prompt (instead of the current “student $”), with an environment
variable that works as follows:
o export MYPROMPT=@
o ./3000shell
o student @
5. [2] Remove or comment out line 237 (the call to find_binary()). Change just ONE line in the rest
of the code (or just characters) to make 3000shell still work the same.
Note: you may need to add one extra line in order to get the code to compile.
6. [2] Implement a built-in 3000kill command that works like the standard kill command, but with
simplified basic functionality as follows:
o 3000kill -TERM (you can replace the TERM with another signal)
o Using signal numbers (e.g., 15/9 as opposed to TERM/KILL) will not be penalized.
o Anyone with your 3000shell should be able to verify it by 3000killing a running program.


欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468