Operating System Assignment
Autor: louis fontaine • November 23, 2017 • Coursework • 1,501 Words (7 Pages) • 756 Views
Concordia University
Operating Systems
Theory Assignment#1
Question 1
- P1 = 15 + 10 +10
P1 = 35 units of time
P2 = 10 + 5 + 15
P2 = 30 units of time
With a single programmed operating system:
Ptot = P1 + P2
Ptot = 35 + 30
Ptot = 65 units of time
[pic 1]
- With a multiprogrammed operating system, we don’t have I/O burst time:
Ptot = (15 + 10) + (10 + 15)
Ptot = 50 units of time
[pic 2]
- With a single programmed operating system, Troughput = 2/65
And with a multiprogrammed operating system, Troughput = 2/50
Question 2
- To complete the load of N processes in a small time, we have to execute all the process at the same time and have a multiprogrammed OS with a capacity n.
- With a single programmed OS and interruptions, the time to complete the load of N process is going to be to be longer than the addition time because processes can’t be executed at the same time and interruptions take times.
Question 3
[pic 3]
Question 4
Context switch need to be atomic otherwise it can be interrupted by other processes and if context switch is interrupted before saving the block for a restoration, it will lose data.
Question 5
The user threads share data with all other threads inside the process while kernel threads are threads which are fully executed in kernel mode, and there is no user mode in it.
Question 6
- This solution satisfies mutual exclusion of the critical section because it has flags and turn variable. In the case of both processes set their flag to TRUE, only the process whose turn will succeed. After, the process which is waiting will enter in the critical section when and only when the other will update the value of turn.
- This solution satisfies the “progress” requirement also because it has flags and turn variable. When a process wants to access to critical section, it set their flag variable to TRUE and enter. The other process’s value is set to turn, exiting its critical section. If the other process wants to enter in critical section again, he just has to do the same thing.
- This solution satisfies the bounded waiting requirement by using turn variable. If two processes want to enter in their critical sections, they set their value of flag to TRUE but only the thread can proceed, the other one wait.
Question 7
Three semaphores mutex, goB, and goC, which are initialized to 1, 0 and 0 respectively
[pic 4]
- All three processes block permanently if Process B start, it decreases mutex by one and mutex is equal to 0, then all semaphores are equal to 0 and all three processes are blocked
- Two processes block permanently if Process A execute entirely, then mutex = 1, goB = 1 and goC = 0, then process C start, first line of process C execute then mutex = 0, goB = 1, goC = 0 and process B and C are blocked
- No process blocks permanently when Process A execute entirely, then mutex = 1, goB = 1 and goC = 0 then Process B execute entirely and mutex = 1, goB = 0 and goC = 1, then Process C execute entirely and mutex = 1, goB = 0 and goC = 0
Question 8
Monitor FileControl {
Condition readers, writers;
int activereaders = 0;
boolean writing = False;
int waitingwriters = 0 ;
WriterEntry() {
If (writing > 0)){
waitingwriters = waitingwriters+1;
writers.wait();
...