Uploaded by S. M. Atikullah Khan

Operating system qus

advertisement
i) answer:
From the computer’s point of view, the operating system is the program most intimately involved
with the hardware. In this context, we can view an operating system as a resource allocator. A
computer system has many resources that may be required to solve a problem: CPU time, memory
space, file-storage space, I/O devices, and so on. The operating system acts as the manager of these
resources. Facing numerous and possibly conflicting requests for resources, the operating system must
decide how to allocate them to specific programs and users so that it can operate the computer system
efficiently and Fairly.
A slightly different view of an operating system emphasizes the need to control the various I/O devices
and user programs. An operating system is a control program. A control program manages the
execution of user programs to prevent errors and improper use of the computer. It is especially
concerned with the operation and control of I/O devices.
ii) answer:
I would like to follow the Multitasking Operating system. Types of Multitasking Operating System:
There are two types of multitasking operating system
Cooperative Multitasking:Windows and Mac OS used cooperative multitasking. A Windows program
would do some small unit of work in response to a message and then relinquish the CPU to the
operating system until the program got another message. That worked well, as long as all programs
were written with consideration for other programs and had no bugs.
Preemptive Multitasking:
Desktop operating systems use preemptive multitasking. Unix used this form of multitasking from the
beginning. Windows started using preemptive multitasking with Windows NT and Windows 95.
Macintosh gained preemptive multitasking with OS X. This type of operating system programs to tell
them it’s time to give another program a turn with the CPU.
Multitasking Operating System Benefits:
In the Multitasking Operating System, memory, hard drive, and virtual memory are better managed.
Processor time is also well used as the wait time is less.
Suppose any user is downloading any file from the internet. Now he can do other tasks on the
computer without waiting for the file to download completely.
One process cannot change data of another process in the main memory. Each process can only use
his own space allocated.
If any program generates errors then other programs running on the computer are not affected by it. For
example, if Google chrome crashes then your data in MS Word is not affected.
CMT can handle multiple users at a time. Every user can run their own programs independently of
other users.
Multiple apps can run on smartphones and they use multitasking techniques.
i) answer:
CPU switching generally refers to the “context switching”mode of the CPU. Switching the CPU from one
process to another process requires performing a state save of the current process and a state restore
of a different process. This task is known as a context switch.
As the operating system supports multiprogramming, it needs to keep track of all the processes. For
this task, the process control block (PCB) is used to track the process’s execution status. Each block of
memory contains information about the process state, program counter, stack pointer, status of opened
files, scheduling algorithms, etc.. When an interrupt occurs, the system needs to save the current
context of the process running on the CPU so that it can restore that context when its processing is
done, essentially suspending the process and then resuming it. The context is represented in the PCB
of the process. It includes the value of the CPU registers, the process state, and memory-management
information. Generically, we perform a statesave of the current state of the CPU, be it in kernel or user
mode, and then a state restore to resume operations.
So We can say that PCB plays a very important role in Context switching/CPU switching.
ii) Answer:
As a process executes, it changes state. The state of a process is defined in part by the current activity
of that process. A process may be in one of the following states:
• New. The process is being created.
• Running. Instructions are being executed.
• Waiting. The process is waiting for some event to occur (such as an I/O
completion or reception of a signal).
• Ready. The process is waiting to be assigned to a processor.
• Terminated. The process has finished execution.
These names are arbitrary, and they vary across operating systems. It is important to realize that only
one process can be running on any processor at any instant. Many processes may be ready and
waiting, however.
The state diagram corresponding to these states is presented in the Figure below:
3.i ) answer:
Process
Arrival time
Brust time
Completion
time
TurnAround
Time
Waiting
Time
Response
Time
j1
8
2
17
9
7
11-8=3
j2
7
3
19
12
9
8-7=1
j3
7
6
25
18
12
9-7=2
j4
4
7
23
19
12
4-4=0
j5
6
3
16
10
7
6-6=0
My Id number is: 171-15-8781
171158781%3=0
0+1=1
So, Quantum time= 1
Gantt Chart:
Total waiting time (7+9+12+12+7)=47
Average WT= 47/5=9.4
Average Response time=(3+1+2+0+0)/5=1.2
3.ii) Answer:
Priority
Process
Arrival time
Brust time
Completion
time
TurnAround
Time
Waiting Time
4
j1
4
4
26
22
19
0
j2
3
2
5
2
0
3
j3
6
5
23
17
12
1
j4
9
5
18
11
6
1
j5
6
7
13
7
0
My id = 171-15-8781, which is an odd number. So 0 is the maximum priority.
Gantt chart:
Total waiting time = 37
Total TurnAround Time = 59
Download