OS Sheet (3) Solution

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Helwan University First Term, Academic Year 2022/2023

Faculty of since M 317 - Operating System

Math. Department Sheet 2


St. Name:

First: Choose the correct answer (1 mark)


1. .............. refers to a situation in which a process is ready to execute but is
continuously denied access to a processor in deference to other processes.

A) Synchronization B) Mutual Exclusion

C) Dead lock D) Starvation

2. Which of the following is not the approach to dealing with deadlock?

A) Prevention B) Avoidance

C) Detection D) Deletion

3. Which of the following are the states of a five state process model?

i) Running ii) Ready iii) New iv) Exit v) Destroy

A) i, ii, iii and v only B) i, ii, iv and v only

C) i, ii, iii, and iv only D) All i, ii, iii, iv and v

4. State which statement is true for Suspended process?

i) The process is not immediately available for execution.

ii) The process may be removed from suspended state automatically without removal
order.

A) i only B) ii only
C) i and ii only D) None

5. The different types of tables maintained by the operating system are

A) memory, logical , I/O file B) memory, I/O, file, physical

C) memory, I/O, file, process D) memory, logical, I/O, physical

6. The simplest way of deadlock is to ...

A) preempt a resource B) rollback


C) kill one of the processes D) lock one of the processes

7. Throughput of a system is

A) Number of programs processed by it per unit time

B) Number of times the program is invoked by the system


C) Number of requests made to a program by the system
D) None of the above

8. Round robin scheduling is essentially the preemptive version of ...........

A) first in first out B) shortest job first


C) shortest remaining D) longest time first

9. Which of the following describes the ability of an OS to support multiple, concurrent


paths of execution within a single process?

A) Multithreading B) Multiprocessing
C) Multitasking D) Multiprogramming

10. A thread is a .................... precess.


A) heavy weight B) multiprocess
C) inter thread D) light weight

11. Timer is used to prevent a single


A. Job
B. Time
C. Computer
D. Information

12. Interrupts make an operating system more

A. Rigid
B. Expensive
C. Control
D. Flexible

13. Main function of shared memory is:


A. to use primary memory efficently
B. to do intra process communication
C. to do inter process communication
D. none of above

13. Disk scheduling includes deciding


A. which should be accessed next
B. order in which disk access requests must be serviced
C. the physical location of the file
D. the logical location of the file

14. Which scheduling policy is best suited for time-sharing operating systems
A. Shortest job first
B. Round robin
C. First come first serve
D. Elevator

15. In operating system, each process has its own


a) address space and global variables b) open files
c) pending alarms, signals and signal handlers d) all of the mentioned
16. A process can be terminated due to
a) normal exit b) fatal error
c) killed by another process d) all of the mentioned

17. What is the ready state of a process?


a) when process is scheduled to run after some execution
b) when process is unable to run until some task has been completed
c) when process is using the CPU d) none of the mentioned

18. What is interprocess communication?


a) communication within the process
b) communication between two process
c) communication between two threads of same process
d) none of the mentioned

19. A set of processes is deadlock if


a) each process is blocked and will remain so forever
b) each process is terminated
c) all processes are trying to kill each other
d) none of the mentioned

20. A Process Control Block(PCB) does not contain which of the following :
a) Code b) Stack
c) Bootstrap program d) Data

21. The number of processes completed per unit time is known as __________
a) Output b) Throughput
c) Efficiency d) Capacity

22. The state of a process is defined by:


a) the final activity of the process
b) the activity just executed by the process
c) the activity to next be executed by the process
d) the current activity of the process

23. Which of the following is not the state of a process?


a) New b) Old
c) Waiting d) Running

24. The Process Control Block is:


a) Process type variable b) Data Structure
c) A secondary storage section d) A Block in memory

25. A single thread of control allows the process to perform:


a) only one task at a time
b) multiple tasks at a time
c) only two tasks at a time
c) all of the mentioned

26. The objective of multi-programming is to :


a) Have some process running at all times
b) Have multiple programs waiting in a queue ready to run
c) To minimize CPU utilization
d) None of the mentioned

27. When the process issues an I/O request :


a) It is placed in an I/O queue b) It is placed in a waiting queue
c) It is placed in the ready queue d) It is placed in the Job queue

28. When a process terminates :


a) It is removed from all queues
b) It is removed from all, but the job queue
c) Its process control block is de-allocated
d) Its process control block is never de-allocated
29. In a time-sharing operating system, when the time slot given to a process is completed,
the process goes from the running state to the :
a) Blocked state b) Ready state
c) Suspended state d) Terminated state

30. When several processes access the same data concurrently and the outcome of the
execution depends on the particular order in which the access takes place, is called
a) dynamic condition b) race condition
c) essential condition d) critical condition

31. If a process is executing in its critical section, then no other processes can be executing
in their critical section. This condition is called
a) mutual exclusion b) critical exclusion
c) synchronous exclusion d) asynchronous exclusion

32. Which one of the following is a synchronization tool?


a) thread b) pipe
c) semaphore d) socket

33. A semaphore is a shared integer variable


a) that can not drop below zero
b) that can not be more than zero
c) that can not drop below one
d) that can not be more than one

34. Mutual exclusion can be provided by the


a) mutex locks b) binary semaphores
c) both mutex locks and binary semaphores d) none of the mentioned

35. Process synchronization can be done on


a) hardware level b) software level
c) both hardware and software level d) none of the mentioned
36. A monitor is a module that encapsulates
a) shared data structures
b) procedures that operate on shared data structure
c) synchronization between concurrent procedure invocation
d) all of the mentioned

37. Inter process communication :


a) allows processes to communicate and synchronize their actions when using the same
address space
b) allows processes to communicate and synchronize their actions without using the
same address space
c) allows the processes to only synchronize their actions without communication
d) none of the mentioned

38. Scheduling of threads are done by

A. input
B. output
C. operating system
D. memory

39. Process synchronization of programs is done by

A. input
B. output
C. operating system
D. memory

40. A process needs

A. through put to execute


B. timer to execute
C. resources to execute
D. both a and b

41. An executed program of computer system is called?


A. trap
B. process
C. program
D. interrupt

42. A single threaded process of operating system programs has

A. One program counter


B. Two program counters
C. Three program counters
D. Four program counters

Second : Answer the following (2 mark)


1. What is the difference between a program and a process?

A process is an executing program. Therefore, programs are static while


processes are dynamic.

2. What is the purpose of the process table? The operating system uses the
process table to keep track of the state of all the processes.

3. Explain the three states of a process.

Processes can be in one of three states: running, ready, or waiting. The


running state means that the process has all the resources it needs for
execution and the operating system has given it permission to use the
processor. The waiting state means a process is waiting for some external
event to occur such as user input or a disk access. The ready state means a
process has all the resources it needs but is waiting for permission to use
the processor.

4. What is a time quantum?


A time quantum is the amount of time a process is allowed to execute
before it is preempted and use of the processor is given to another process.

5. Which scheduling strategies are preemptive and which are not?

First Come First Serve and Shortest Process Next are non-preemptive
while Round Robin is preemptive.

Synchronization

1. What is synchronization?

Synchronization is the orderly sharing of system resources by processes.

2. Explain the following terms: critical resource, critical section, mutual


exclusion.

Critical Resource:
a resource shared with constraints on its use (e.g., memory, files,
printers, etc.)

Critical Section:
code that accesses a critical resource

Mutual Exclusion:
at most one process may be executing a Critical Section with respect
to a particular critical resource simultaneously

3. What are two ways that semaphores can be implemented?

One way to implement semaphores in computers is to use a flag (i.e., a bit


of memory) that can be tested and set to either 0 or 1 in a single machine
operation. Another way to implement a semaphore is to use a count rather
than just two values.
4. Why must a machine have a test-and-set instruction in order to implement
semaphores?

If both operations do not occur during the same instruction, it is possible


for a process to be preempted while testing or setting a semaphore value.
Such a condition compromises the effectiveness of the semaphore in
regulating access to critical sections.

7. What are turnaround time and response time?


Turnaround time is the interval between the submission of a job and its
completion. Response time is the interval between submission of a request, and
the first response to that request.
Deadlock

1. What is deadlock?

Deadlock is a situation that can arise when two or more processes hold
resources and request others. Some process holds a resource that another
wants while requesting a second resource, and the other process holds the
second resource while requesting the first. Hence, neither process can
progress.

2. What three conditions must exist in order for deadlock to occur?

(1) mutual exclusion, (2) hold-and-wait, and (3) no preemption.

3. How might an operating system attack the third condition necessary for
deadlock in order to solve the problem of deadlock?

The operating system may forcibly deallocate resources from deadlocked


processes thus attacking the condition of no preemption.

4. How might an operating system attack the second condition necessary for
deadlock in order to solve the problem of deadlock?

The operating system may attack the second condition by requiring


processes to request all of their resources at the same time.

You might also like