LOGICAL
ADDRESS CALCULATION
Useful for anyone learning the basics of computer science. Particularly useful for NET and any state SLET exam aspirants appearing for Computer Science Paper. By Vani C
LOGICAL
ADDRESS CALCULATION
|
(a) Disk scheduling
|
(1) Round robin
|
|
(b) Batch processing
|
(2) Scan
|
|
(C)Time sharing
|
(3) LIFO
|
|
(d) Interrupt processing
|
(4) FIFO
|
|
(A)
|
Caching
|
(B)
|
Termination
|
|
(C)
|
Swapping
|
(D)
|
Interruption
|
|
(A)
|
Virtual memory
|
(B)
|
Interrupts
|
|
(C)
|
Cache memory
|
(D)
|
Secondary memory
|
|
(A)
|
Dead lock Prevention
|
(B)
|
Dead lock Avoidance
|
|
(C)
|
Dead lock Detection
|
(D)
|
Dead lock creation
|
Hi all,
CBSE has published the notification for the conduct of the JRF and NET EXAM exam in the month of November, 2017.
Click on the following link for more details....
http://cbsenet.nic.in/CMS/Handler/FileHandler.ashx?i=File&ii=49&iii=Y
This question is based on the concept of deadlock avoidance. In order to understand the theory behind this concept, refer to my earlier post on the same topic.
http://ugcnetsolved-computerscience.blogspot.in/2017/04/deadlock-avoidance.html
Let us try to understand the question and solve it based on the theory given above.
Consider a system with twelve magnetic tape drives and three processes p1,p2 and p3. Process p1 requires maximum ten tape drives, process p2 may need as many as four tape drives and p3 may need upto nine tape drives. Suppose that at time t1, process p1 is holding five tape drives, process p2 is holding two tape drives and process p3 is holding three tape drives. At time t1, system is in :
(1) Safe state
(2) Unsafe state
(3) Deadlocked state
(4) Starvation state
Explanation:-
Below is a table given depicting the maximum needs and current needs of each process.
| MAXIMUM NEEDS | CURRENT NEEDS | |
|---|---|---|
| p0 | 10 | 5 |
| p1 | 4 | 2 |
| p2 | 9 | 3 |
Remember, there is no specific formula to solve this problem. It is more of understanding, logic and common sense for solving this.
Total number of magnetic tapes = 12
Already allocated = 10
Number of free magnetic tapes = 12 – 10 =2
From the table, we can understand that process p2 requires 2 more tapes for completion and since two tapes are free, they are allocated to process p2.
Process p2 completes its execution, and returns all the four tapes to the sytem.
So, number of free tape drives = 4.
Since process p1 is allocated 5 tape drives, but has a maximum of 10, it may then request 5 more tape drives. Since they are unavailable, process p1 must wait. Similarly, process p3 may request an additional 6 tape drives and have to wait, resulting in a deadlock. So the system is in deadlocked state.
The correct option is 3.
Deadlock avoidance is a very important topic in operating system. So, first let us understand the basics related to deadlock.
In a multiprogramming environment, there are several processes running concurrently. Each of these processes may compete for a limited or finite number of resources. If a process requests resource, and it is not available, then it has to wait for the resource, and so it enters into wait state. But the waiting process may never change state, because the resources they have requested are held by other waiting processes. Such a situation is called deadlock.
A system is in a safe state if it can allocate resources to each process in some order and still avoids a deadlock.
Let us consider a system with 12 magnetic tape drives and 3 processes. p0,p1 and p2. Process p0 requires 10 tape drives, process p1 requires 4 tape drives and process p2 may need up to 9 tape drives. Suppose, at time t0, process p0 is holding 5 tape drives, process p1 is holding 2 tape drives and process p2 is holding 2 tape drives.
| MAXIMUM NEEDS | CURRENT NEEDS | |
|---|---|---|
| p0 | 10 | 5 |
| p1 | 4 | 2 |
| p2 | 9 | 2 |
TOTAL NUMBER OF TAPE DRIVES = 12
NUMBER OF FREE TAPE DRIVES = 12-9=3
p1 requires 2, allotted 2, so number of free tape drives = 1
Since p1 got its maximum need, it finishes its work and returns all the 4 tape drives.
NUMBER OF FREE TAPE DRIVES NOW = 1+4 = 5
p0 requires 5, allotted 5, so number of free tape drives = 0
Since p0 got its maximum need, it finishes its work and returns all the 10 tape drives.
NUMBER OF FREE TAPE DRIVES NOW = 10
p2 requires 7, allotted 7, and p2 also got its maximum need and it finishes its work and returns all the tape drives.
The system is in safe state if the sequence is <p1,p0,p2>.
Let us consider, that at time t1, process p2 requests 1 tape drive and is allotted 1 more. So, the maximum and current needs are depicted as below.
| MAXIMUM NEEDS | CURRENT NEEDS | |
|---|---|---|
| p0 | 10 | 5 |
| p1 | 4 | 2 |
| p2 | 9 | 3 |
TOTAL NUMBER OF TAPE DRIVES = 12
NUMBER OF FREE TAPE DRIVES = 12 - 10=2
p1 requires 2, allotted 2, so number of free tape drives = 0
Since p1 got its maximum need, it finishes its work and returns all the 4 tape drives.
Now, neither p0 nor p2 can be allotted the rest for completion. So, the system is in unsafe state.
Let us try to solve some problems on deadlock avoidance.
An operating system using banker’s algorithm for deadlock avoidance has ten dedicated devices (of same type) and has three processes P1, P2 and P3 with maximum resource requirements of 4, 5 and 8 respectively.
There are two states of allocation of devices as follows :
State 1 Processes P1 P2 P3
Devices allocated 2 3 4
State 2 Processes P1 P2 P3
Devices allocated 0 2 4
Which of the following is correct ?
(A) State 1 is unsafe and state 2 is safe.
(B) State 1 is safe and state 2 is unsafe.
(C) Both, state 1 and state 2 are safe.
(D) Both, state 1 and state 2 are unsafe.
Ans:- A
EXPLANATION:-
| MAXIMUM NEEDS | CURRENT NEEDS | |
|---|---|---|
| p1 | 4 | 2 |
| p2 | 5 | 3 |
| p3 | 8 | 4 |
NUMBER OF FREE DEVICE = 10
NUMBER OF FREE DEVICE = 10-9=1
Since the number of free device is just 1, it can be allocated to any of the processes p1,p2 or p3.
p1 requires 2, as it is allocated only 2.
p2 requires 2, because it is already allocated 3 and its maximum need is 5.
p3 requires 4, because it is already allocated 4 and its maximum need is 4.
Since, none of the processes requirement can be satisified, the state 1 is in unsafe state.
| MAXIMUM NEEDS | CURRENT NEEDS | |
|---|---|---|
| p1 | 4 | 0 |
| p2 | 5 | 2 |
| p3 | 8 | 4 |
Let us see whether state 2 is in safe or unsafe state.
TOTAL NUMBER OF FREE DEVICES = 10
NUMBER OF FREE DEVICE=10-6=4
Process p1 requires a maximum of 4 devices and they can be allocated, because the number of free device right now is 4. Since p1 gets its maximum need, it completes the process and returns all of the 4 devices.
Process p2 requires a maximum of 5, which can be allocated right now. p2 completes its process and returns all the 5 devices.
Process p3 requires a maximum of 8, which also can be allocated right now. So, p3 also can finish its execution successfully.
So, state 2 is in safe state
So, the correct answer for the question is State 1 is in unsafe state and state 2 is in safe state which is option A.
Ans:-A
Ans:-A
Ans:-C
Explanation:- CFL's are closed under union, concatenation, and Kleene closure. But not under intersection or difference. So the correct answer is option C.
Ans:-B
Ans:-A
Ans:-B
Ans:-D
Ans:-B
Ans:-D
Ans:-C
Ans:-D
Ans:-B
Ans:-B
Ans:-A
The number of nodes in a complete binary tree of height h (with roots at level 0) is equal to (A) 20 + 21 + ..... 2hAns:-A