Homework 1: Processes
1. (5pts) What is the difference between symmetric and
asymmetric multiprocessing?
2. (5pts) What is the difference between a loosely coupled
system and a tightly coupled system? Give examples
3. (5pts) What is a context switch, what actions are taken in
the kernel, and how much time it takes in today's
systems?
4. (5pts) What are the main types of system calls? Describe
their purpose.
5. (30pts) Develop a small program in C (or Java) using system
calls (e.g. fork(), waitpid(), exit(), kill(), ..)
that does the following:
- a parent process creates a child process that prints its
PID
- the child creates a grandchild and sleeps 120 seconds
- the grandchild immediately exits
- the parent sleeps for 60 seconds and then kills all the
processes
(A sample program written in C is provided in Figure 4.8. For detailed
information about the calls use the Internet (e.g., http://www.softpanorama.org/Internals/unix_system_calls_links.shtml))
Additional exercise (not required):
6. Develop an execution driven simulator (C or Java)
for a multiprocessor following these steps:
- create a process for every processor (# processors is an
argument to the program)
- in each process start executing a program using the exec()
system call (for example a simple program that prints
"hello I am processor nr " and the processor
number.)
- each process exits when done
- the parent process should check when the children are
done (i.e., the processors finished execution of their
programs) and then exit
Resources:
- Text book
- Java
tutorial
- List of system Calls in Unix for a C implementation - see
below for an overview
- Java implementation - see http://java.sun.com/products/jdk/1.2/docs/api/index.html
select class java.lang and look especially to the class
java.class.Processjava.lang
Class Process
java.lang.Object
|
+--java.lang.Process
| Process
related Calls in Unix Systems |
| Process Creation and Termination |
exec() fork()
wait()
exit()
|
| Process Owner and Group |
getuid() geteuid()
getgid()
getgid()
|
| Process Identity |
getpid() getppid()
|
| Process Control |
signal() kill()
alarm()
|
| Change Working Directory |
chdir() |