The Operating Systems Concurrency Computer Science Essay

Published: November 9, 2015 Words: 1427

1. Why are distributed systems desirable? To be able to say why a distributed system is desirable we first need to distinguish what a distributed system is. A distributed system is a system which has a set of processors; these processes do not share the main memory or a clock. A distributed system may either be a client-server or peer to peer systems.

There are four reasons to why a distributed system is desirable these being resource sharing, this allows the system to share file at a remote site and also process information. If many users are connected together then a user from one site would be able to access the information at another site. Computation speedup, this is when a computation can be split into sub computations which can be run concurrently, reliability if one site on a distributed system fails or goes down it will not affect the rest of the system as the other sites will carry on operating.

2. What is multiprogramming? What are its advantages over uni-programming? How is it different from multiprocessing?

Multiprogramming is a form of parallel processing. Multiprogramming allows several programs to be running/active at the same time, whilst it still runs on a single processor. Each program running/active will be organised into jobs which will increase cpu utilisation.

Multiprogramming differs from multiprocessing as the uniprocessor is not concurrently executing commands for all the programs running. The processor with go to each program execute a command and move on to the program which Is next in the queue. The previous programs will still be running/active but will just wait until it is their turn and the uniprocessor appears again. A multiprocessor system has more than one cpu.

.

3. How do "kernel mode" (or "supervisor mode") and "user mode" instructions differ?

Kernel mode is node is known as an unrestricted node and a user node is known as restricted nodes.

Kernel mode is also known as a privileged CPU mode, the CPU performs operations that are substantially given by the architecture.

User mode is more expensive than supervisor mode due to the context switch and to keep the system secure cache must be flushed; if this is not flushed you will not be able to access what you are allowed to access. The context switch allows the switch to kernel mode to perform specific tasks, after that the CPU scheduler starts the timer interrupts which them switches everything to kernel mode, then next task is then executed after all this is completed everything is switched back to user mode where the next task in the queue can finish.

4. Which of the following instructions should be privileged?

a. disable all interrupts

b. read the time-of-day clock

c. set the time-of-day clock

d. read the timer

e. set the value of the timer

f. clear memory

g. switch from user mode to privileged mode

A privileged instruction has been defined as

“A class of instructions, usually including storage protection setting, interrupt handling, timer control, input/output, and special processor status-setting instructions, that can be executed only when the computer is in a special privileged mode that is generally available to an operating or executive system, but not to user programs.”

By McGraw-Hill Dictionary of Scientific & Technical Terms, 6E, Copyright © 2003 by The McGraw-Hill Companies, Inc

So a privileged instruction is one where you can set a timer control, Input/Output I/O interrupt handling and storage protection. We can come to the conclusion that they are all privileged instructions

5. What is meant by "atomic operation"? Why is it important in cooperating processes?

A atomic operation is when the processor can concurrently read and write a location in the same bus operation. This means that no other processor or input/output device can read or write until the operation is complete. An atomic operation can either not be preformed or be preformed and finished.

An atomic operating is guaranteed to finish and execute each single CPU cycle, so now interrupts will happen to stop this process. As an atomic operation is implemented by using CPU instructions, this means that there are differences between each of the instructions and they use different hardware.

6. Explain the differences in the degree to which the following scheduling algorithms discriminate in favour of short processes:

a. FCFS

First Come First Served is one of the simplest algorithms, as it does what the name says it does the process which asks for the CPU first will then be first in queue. First Come First Serve is non pre-emptive meaning that when a process has been allocated the CPU, the process will stay in the CPU until it is released through termination.

It is good for short processes as they will then be completed quicker than the larger processes, instead of being at the back of the queue. If a larger process is first then the shorter process will have to wait for the larger one to finish, this then means scheduling is faster.

b. RR

Round Robin is when each process will each get a small amount of CPU time or time quantum. After each process has had a small amount of CPU the process will then be moved to the end of the ready queue. With RR uses time interrupts to release long running jobs from the CPU based on time interrupts this is so the shorter jobs can also get a fair amount of CPU.

c. Multilevel feedback queues

for multilevel feedback queues the ready queue is separated into queues, the foreground which is interactive and the background which is batch. The two queues I have mentioned have their own algorithm foreground is Round Robin and background is First Come Frist Served.

7. Consider the following set of processes, with burst time (aka computation time) given in milliseconds:

Process

Burst time

Priority

P1

10 ms

3

P2

1 ms

1

P3

2 ms

3

P4

1 ms

4

P5

5 ms

2

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.

i. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, non-preemptive priority (smaller priority number means higher priority), and RR (quantum=1) scheduling.

ii. What is the turnaround time of each process for each of the scheduling algorithms in (i)?

iii. What is the waiting time of each process for each of the scheduling algorithms in (i)?

iv. Which of the schedules in (i) results in the minimal average waiting time (over all processes)?

First come first served

Gannt chart

P5

P4

P3

P2

P1

0 10 11 13 14 19

Turnaround time

Process

Burst time

Turnaround time

P1

10 ms

10ms

P2

1 ms

1 ms

P3

2 ms

2 ms

P4

1 ms

1 ms

P5

5 ms

5ms

Waiting time

P1 = 0 P2 = 10 P3 = 11 P4 = 13 P5 = 14

Average Waiting time

( 0 + 10 + 11 + 13 + 14)/5 = 9.6

Shortest Job First (SJR) Non-Preemptive

Gannt Chart

P2

P4

P3

P5

P1

0 1 2 4 9 19

Turnaround Time

Process

Burst time

Turnaround time

P2

1 ms

1ms

P4

1 ms

1ms

P3

2 ms

2ms

P5

5 ms

5ms

P1

10 ms

10ms

Waiting time

P2 = 0 P4 = 1 P3 = 2 P5 = 4 P1 = 9

Average waiting time

(0 + 1 + 2 + 4 + 9)/5 = 3.2

Non-preemptive priority

Gannt chart

P4

P3

P1

P5

P2

0 1 6 16 18 19

Turnaround time

Process

Burst time

Turnaround time

P2

10 ms

1 ms

P5

1 ms

5ms

P1

2 ms

10ms

P3

1 ms

2ms

P4

5 ms

1ms

Waiting time

P1 = 6 P2 = 0 P3 = 16 P4 = 18 P5 = 1

Average time

(6 + 0 + 16 + 18 + 1)/5 = 8.2

Round Robin (quantum=1) scheduling.

Gannt Chart

P1

P5

P1

P5

P1

P5

P1P1

P2

P3

P4

P5

P1

P3

P5

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 19

Turnaround time

Process

Burst time

Turnaround time

P1

10 ms

P2

1 ms

P3

2 ms

P4

1 ms

P5

5 ms

Waiting time

P1 = 0 + 4 +2 + 1 + 1 + 1 = 9; P2=1; P3 = 2 + 3 = 5; P4 = 3; P5 = 4 + 2 +1 +1 +1 = 9

Average waiting time

(9 + 1 + 5 + 3 + 9)/5 = 5.4