Os Ans
Os Ans
Os Ans
1. What is Concurrency?
Concurrency is the execution of the multiple instruction sequences at the same time. It
happens in the operating system when there are several process threads running in parallel.
The running process threads always communicate with each other through shared memory or
message passing.
2. What is Mutual Exclusion?
A mutual exclusion (mutex) is a program object that prevents simultaneous access to a
shared resource. This concept is used in concurrent programming with a critical section, a
piece of code in which processes or threads access a shared resource.
Disadvantages:
● Does not try to optimize seek time
● May not provide the best possible service
SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed
first. So, the seek time of every request is calculated in advance in the queue and then they are
scheduled according to their calculated seek time. As a result, the request near the disk arm
will get executed first. SSTF is certainly an improvement over FCFS as it decreases the
average response time and increases the throughput of system.Let us understand this with the
help of an example.
Advantages:
● Average Response Time decreases
● Throughput increases
Disadvantages:
SCAN: In SCAN algorithm the disk arm moves into a particular direction and
services the requests coming in its path and after reaching the end of disk, it
reverses its direction and again services the request arriving in its path. So, this
algorithm works as an elevator and hence also known as elevator algorithm.
As a result, the requests at the midrange are serviced more and those arriving
behind the disk arm will have to wait.
Advantages:
● High throughput
● Low variance of response time
● Average response time
Disadvantages:
● Long waiting time for requests for locations just visited by disk arm
● CSCAN: In SCAN algorithm, the disk arm again scans the path that has
been scanned, after reversing its direction. So, it may be possible that too
many requests are waiting at the other end or there may be zero or few
requests pending at the scanned area.
Multithreading Models
Conditions for deadlock:
1. Mutual exclusion: When two people meet in the landings, they can’t just walk through
because there is space only for one person. This condition allows only one person (or
process) to use the step between them (or the resource) is the first condition necessary
for the occurrence of the deadlock.
2. No preemption: For resolving the deadlock one can simply cancel one of the processes
for other to continue. But the Operating System doesn’t do so. It allocates the resources
to the processors for as much time as is needed until the task is completed. Hence,
there is no temporary reallocation of the resources. It is the third condition for deadlock.
3. Hold and wait: When the two people refuse to retreat and hold their ground, it is called
holding. This is the next necessary condition for deadlock.
4. Circular wait: When the two people refuse to retreat and wait for each other to retreat so
that they can complete their task, it is called circular wait. It is the last condition for
deadlock to occur.
Deadlock prevention:
1. Eliminate Mutual Exclusion
It is not possible to dis-satisfy the mutual exclusion because some resources, such as
the tape drive and printer, are inherently non-shareable.
2. Eliminate hold and wait
Allocate all required resources to the process before the start of its execution, this way
hold and wait condition is eliminated but it will lead to low device utilization. for example,
if a process requires printer at a later time and we have allocated printer before the start
of its execution printer will remain blocked till it has completed its execution. The
process will make a new request for resources after releasing the current set of
resources. This solution may lead to starvation.
3. Eliminate No preemption
Preempt resources from the process when resources required by other high priority
processes.
4. Eliminate Circular Wait
Each resource will be assigned with a numerical number. A process can request the
resources increasing/decreasing. order of numbering.
For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4,
R3 lesser than R5 such request will not be granted, only request for resources more
than R5 will be granted.
The main drawback of single threading systems is that only one task can be performed at a
time, so to overcome the drawback of this single threading, there is multithreading that allows
multiple tasks to be performed.
For example:
In the above example, client1, client2, and client3 are accessing the web server without any
waiting. In multithreading, several tasks can run at the same time.
In an operating system, threads are divided into the user-level thread and the Kernel-level
thread. User-level threads handled independent form above the kernel and thereby managed
without any kernel support. On the opposite hand, the operating system directly manages the
kernel-level threads. Nevertheless, there must be a form of relationship between user-level and
kernel-level threads.
There exists three established multithreading models classifying these relationships are:
The disadvantage of this model is that since there is only one kernel-level thread schedule at
any given time, this model cannot take advantage of the hardware acceleration offered by
multithreaded processes or multi-processor systems. In this, all the thread management is done
in the userspace. If blocking comes, this model blocks the whole system.
In the above figure, the many to one model associates all user-level threads to single
kernel-level threads.
related to it. The process control block is also known as a task control block, entry of
It is very important for process management as the data structuring for processes is
done in terms of the PCB. It also defines the current state of the operating system.
management. Some of these data items are explained with the help of the given
diagram −
Why do the hard drive names start from C and then D ?Why not A and B?
ANS- Its because A and B used to be floppy drives back in the days when floppy drives were
the norm and there were no hard-disks. The letter C was given to any hard disk that the user
installed. The drives A and B have since then been reserved for floppy drives.
In Linux, how does one become the superuser for that particular session?
There are two ways to become the superuser. The first is to log in as root directly. The second
way is to execute the command su while logged in to another user account. The su command
may be used to change one’s current account to that of a different user after entering the
proper password. It takes the username corresponding to the desired account as its argument;
root is the default when no argument is provided.After you enter the su command (without
arguments), the system prompts you for the root password. If you type the password correctly,
you’ll get the normal root account prompt (by default, a number sign: #), indicating that you
have successfully becomesuperuser and that the rules normally restricting file access and
command execution do not apply. For example:
What does Pipe in do in a Linux command?
Pipe is used to combine two or more commands, and in this, the output of one command acts
as input to another command, and this command's output may act as input to the next
command and so on. It can also be visualized as a temporary connection between two or more
commands/ programs/ processes.