CS 3733 Operating Systems, Spring 2003 Assignment 3 Comments
The assignment was graded on a basis of 40 points.
Not all of the questions were graded. Make sure you look at the solutions
and understand them.
If there is anything you don't understand, see me.
Answers to questions: Part 1
- For which of the 10 experiments was the output in the same
order each time it was run?
Your answers may vary but probably you got 1,2,5,6,9 and 10.
- For which of the 10 experiments is the order of the output
determined by the program?
Some people misinterpreted this question. The output is determined by the
program if the output will be the same, independent of what the operating
system does in scheduling. This is only the case for 9 and 10 in which
the wait determines the order of the output.
- For experiments 1, 8, 9 and 10 explain why you think the output
was in the order that it was?
1: There is no preemption and the parent continued to execute after the fork.
Therefore, the first process finishes first. Since FCFS is used the next
process to execute is the first process created by the fork. The processes
execute in the order of their creation.
8: Because the printing is not atomic, the first process will output only a few
characters before losing the CPU. The only preemption is from this non-atomic
printing so after a process prints some characters all other processes print
something be that process gets a chance to print again.
9 and 10: In both these cases the wait causes each process to wait until
its child has printed to the output is in reverse order of creation.
Answers to questions: Part 2
- Is the tree structure the same in each case? How does it differ?
Some people misinterpreted this question. The tree structure (how many
children the processes have, independent of the labeling) is the same in
each case, but the labels are different.
- The process IDs are assigned in the order of creation. In each case
describe the order of creation relative to the tree structure.
1: The processes are ordered in a breadth-first manner with the processes having
the most children being numbered first.
2:The numbering is a mixture of breadth first and depth first. When a process
is created a chain of children is created in order until the chain is done.
3 and 4: Each of these is almost like the first one, but there are some
modifications as a process loses the CPU early.
- Is the order of the output affected by the scheduling of the processes?
Yes, just as in Part 1.
Answers to questions: Part 3
- You should have found that using the semaphore makes each print atomically.
Many people found that the different scheduling methods they tried all
gave the same results.
You cannot conclude from this that the scheduling does not affect
the order of the output.
The order of the output is determined by the order that the processes
reach the wait statement, assuming that the queue is FIFO.
The order at which they reach the wait statement is determined by the
scheduling algorithm.