Home | | Operating Systems | Important Short Questions and Answers: Process Scheduling and Synchronization

Chapter: Operating Systems : Process Scheduling and Synchronization

Important Short Questions and Answers: Process Scheduling and Synchronization

Operating Systems - Process Scheduling and Synchronization - Important Short Questions and Answers: Process Scheduling and Synchronization

 

1.  What is a Thread?

 

A thread otherwise called a lightweight process (LWP) is a basic unit of CPU utilization, it comprises of a thread id, a program counter, a register set and a stack. It shares with other threads belonging to the same process its code section, data section, and operating system resources such as open files and signals.

 

 

2.  What are the benefits of Multithreaded Programming?

 

The benefits of multithreaded programming can be broken down into four major categories:

 

   Responsiveness

 

   Resource sharing

 

   Economy

 

   Utilization of multiprocessor architectures

 

ü Define Thread Cancellation & Target Thread.

 

The thread cancellation is the task of terminating a thread before it has completed. A thread that is to be cancelled is often referred to as the target thread. For example, if multiple threads are concurrently searching through a database and one thread returns the result, the remaining threads might be cancelled.

 

ü     What are the different ways in which a Thread can be cancelled?

 

Cancellation of a target thread may occur in two different scenarios:

 

Asynchronous cancellation: One thread immediately terminates the target thread is called asynchronous cancellation.

Deferred cancellation: The target thread can periodically check if it should terminate, allowing the target thread an opportunity to terminate itself in an orderly fashion.

 

 

5.  Define CPU Scheduling.

 

CPU scheduling is the process of switching the CPU among various processes. CPU scheduling is the basis of multiprogrammed operating systems. By switching the CPU among processes, the operating system can make the computer more productive.

 

6.  What is Preemptive and Non - Preemptive scheduling?

 

Under non - preemptive scheduling once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or switching to the waiting state.

 

 

Preemptive scheduling can preempt a process which is utilizing the CPU in between its execution and give the CPU to another process.

 

7.  What is a Dispatcher?

 

The dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler. This function involves:

Switching context

Switching to user mode

Jumping to the proper location into the user program to restart that program.

 

8.  What is Dispatch Latency?

 

The time taken by the dispatcher to stop one process and start another running is known as dispatch latency.

 

 

 

9.  What are the various scheduling criteria for CPU Scheduling?

 

The various scheduling criteria are,

CPU utilization

Throughput

Turnaround time

Waiting time

Response time

 

10. Define Throughput?

 

Throughput in CPU scheduling is the number of processes that are completed per unit time. For long processes, this rate may be one process per hour; for short transactions, throughput might be 10 processes per second.

 

11. What is Turnaround Time?

 

Turnaround time is the interval from the time of submission to the time of completion of a process. It is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing I/O.

 

12. Define Race Condition.

 

When several process access and manipulate same data concurrently, then the outcome of the execution depends on particular order in which the access takes place is called race condition. To avoid race condition, only one process at a time can manipulate the shared variable.

 

 

13. What is Critical Section problem?

 

Consider a system consists of ‘n‘processes. Each process has segment of code called a critical section, in which the process may be changing common variables, updating a table, writing a file. When one process is executing in its critical section, no other process can allowed executing in its critical section.

 

14. What are the requirements that a solution to the Critical Section Problem must satisfy?

The three requirements

Mutual care, xclusion

Progress

Bounded waiting

 

15. Define Entry Section and Exit Section.

 

The critical section problem is to design a protocol that the processes can use to cooperate. Each process must request permission to enter its critical section. The section of the code implementing this request is the entry section. The critical section is followed by an exit section. The remaining code is the remainder section.

 

 

 

16. Give two hardware instructions and their definitions which can be used for implementing Mutual Exclusion.

 

Test And Set

boolean TestAndSet (boolean &target)

{

 

boolean rv = target; target = true; return rv;

}

 

Swap

void Swap (boolean &a, boolean &b)

{

 

boolean temp = a; a = b;

 

b = temp;

 

17. What is a Semaphore?

A  semaphore       ‘S’  is  a  synchronization tool  which is     an integer    value  that, apart from initialization, is      accessed only through two standard atomic         operations; wait  and signal.

Semaphores can be used to deal with the n-process critical section problem. It can be also used to solve various synchronization problems.

The classic definition of ‘wait’ wait (S)

{

 

while (S<=0) S--;

}

 

The classic definition of ‘signal’ signal (S)

{

S++;

 

}

 

18. Define Busy Waiting and Spinlock.

 

When a process is in its critical section, any other process that tries to enter its critical section must loop continuously in the entry code. This is called as busy waiting and this type of semaphore is also called a spinlock, because the process while waiting for the lock.

 

20. How can we say the First Come First Served scheduling algorithm is Non Preemptive?

 

Once the CPU has been allocated to the process, that process keeps the CPU until it releases, either by terminating or by requesting I/O. So we can say the First Come First Served scheduling algorithm is non preemptive.

 

21. What is Waiting Time in CPU scheduling?

 

Waiting time is the sum of periods spent waiting in the ready queue. CPU scheduling algorithm affects only the amount of time that a process spends waiting in the ready queue.

 

22. What is Response Time in CPU scheduling?

 

Response time is the measure of the time from the submission of a request until the first response is produced. Response time is amount of time it takes to start responding, but not the time that it takes to output that response.

 

23. Differentiate Long Term Scheduler and Short Term Scheduler

 

The long-term scheduler or job scheduler selects processes from the job pool and loads them into memory for execution.

 

The short-term scheduler or CPU scheduler selects from among the process that are ready to execute, and allocates the CPU to one of them.

 

24. Write some classical problems of Synchronization?

 

The Bound -Buffer Problem

The Readers -Writers Problem

The Dining Philosophers Problem

 

25. When the error will occur when we use the Semaphore?

 

When the process interchanges the order in which the wait and signal operations on the semaphore mutex.

When a process replaces a signal(mutex) with wait (mutex)

When a process omits the wait (mutex), or the signal (mutex), or both.

 

26. What is Mutual Exclusion?

 

A way of making sure that if one process is using a shared modifiable data, the other processes will be excluded from doing the same thing. Each process executing the shared data variables excludes all others from doing so simultaneously. This is called mutual exclusion.

 

27. Define the term Critical Regions?

 

Critical regions are small and infrequent so that system through put is largely unaffected by their existence. Critical region is a control structure for implementing mutual exclusion over a shared variable.

 

28. What are the drawbacks of Monitors?

 

 

Monitor concept is its lack of implementation most commonly used programming languages.

There is the possibility of deadlocks in the case of nested monitor’s calls.

 

29.     What are the two levels in Threads?

Thread is implemented in two ways.

User level and Kernel level

 

v     What is a Gantt Chart?

 

A two dimensional chart that plots the activity of a unit on the Y-axis and the time on the X-axis. The chart quickly represents how the activities of the units are serialized.

 

31. Define Deadlock.

 

A process requests resources; if the resources are not available at that time, the process enters a wait state. Waiting processes may never again change state, because the resources they have requested are held by other waiting processes. This situation is called a deadlock.

 

32. What is the sequence in which resources may be utilized?

 

Under         normal  mode   of  operation, a   process  may  utilize   a   resource  in   the following sequence:

Request: I the request cannot be granted immediately, then the requesting process must wait until it can acquire the resource.

Use: The process can operate on the resource

Release: The process release the resource.

 

33. What are conditions under which a deadlock situation may arise?

 

A deadlock situation can arise if the following four conditions hold simultaneously in a system:

Mutual exclusion

Hold and wait

No pre-emption

Circular wait

 

34. What is a Resource-Allocation Graph?

 

Deadlocks can be described more precisely in terms of a directed graph called a system resource allocation graph. This graph consists of a set of vertices V and a set of edges E. The set of vertices V is partitioned into two different types of nodes; P the set consisting of all active processes in the system and R the set consisting of all resource types in the system.

 

35. Define Request Edge and Assignment Edge.

 

A directed edge from process Pi to resource type Rj is denoted by Pi Rj; it signifies that process Pi requested an instance of resource type Rj and is currently waiting for that resource. A directed edge from resource type Rj to process Pi is denoted by RjàPi, it signifies that an instance of resource type has been allocated to a process Pi. A directed edge PiàRj is called a request edge. A directed edge RjàPi is called an assignment edge.

 

36. What are the methods for Handling Deadlocks?

 

The deadlock problem can be dealt with in one of the three ways:

 

Use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlock state.

 

Allow the system to enter the deadlock state, detect it and then recover.

 

Ignore the problem all together, and pretend that deadlocks never occur in the system.

 

 

37. Define Deadlock Prevention.

 

Deadlock prevention is a set of methods for ensure that at least any one of the four necessary conditions like mutual exclusion, hold and wait, no pre-emption and circular wait cannot hold. By ensuring that that at least one of these conditions cannot hold, the occurrence of a deadlock can be prevented.

 

38. Define Deadlock Avoidance.

An alternative method for avoiding deadlocks is to require additional information about how resources are to be requested. Each request requires the system consider the resources currently available, the resources currently allocated to each process, and the future requests and releases of each process, to decide whether the could be satisfied or must wait to avoid a possible future deadlock.

 

39. What are a Safe State and an Unsafe State?

 

A state is safe if the system can allocate resources to each process in some order and still avoid a deadlock. A system is in safe state only if there exists a safe sequence. A sequence of processes <P1,P2,.Pn> is a safe sequence for the current allocation state if, for each Pi, the resource that Pi can still request can be satisfied by the current available resource plus the resource held by all the Pj, with j<i. if no such sequence exists, then the system state is said to be unsafe.

 

40. What is Banker’s Algorithm?

 

Banker’s algorithm is a deadlock avoidance algorithm that is applicable to a resource-allocation system with multiple instances of each resource type. The two algorithms used for its implementation are:

 

Safety algorithm: The algorithm for finding out whether or not a system is in a safe state.

 

Resource-request algorithm: if the resulting resource-allocation is safe, the transaction is completed and process Pi is allocated its resources. If the new state is unsafe Pi must wait and the old resource-allocation state is restored.

 

41. Define Logical Address and Physical Address.

 

address generated by the CPU is referred as logical address. An address seen by the memory unit that is the one loaded into the memory address register of the memory is commonly referred to as physical address.

 

42. What are Logical Address Space and Physical Address Space?

 

The set of all logical addresses generated by a program is called a logical address space; the set of all physical addresses corresponding to these logical addresses is a physical address space.

 

43. What is the main function of the Memory-Management Unit?

 

The runtime mapping from virtual to physical addresses is done by a hardware device called a memory management unit (MMU).

 

44. What are the methods for dealing the Deadlock Problem?

 

Use a protocol to ensure that the system will never enter a deadlock state.

 

 Allow the system to enter the deadlock state and then recover.

 

 Ignore the problem all together, and pretend that deadlocks never occur in the system.

 

45. Differentiate Deadlock and Starvation.

 

A set of processes is in deadlock state when every process in the set is waiting for an event that can be caused only by the other process in the set. Starvation or indefinite blocking is a situation where processes wait indefinitely within the semaphore.

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Operating Systems : Process Scheduling and Synchronization : Important Short Questions and Answers: Process Scheduling and Synchronization |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.