Professional Documents
Culture Documents
OPERATING SYSTEM
CS-1745
ASSIGNMENT
OPERATING SYSTEM
SUBJECT CODE :- CS-1745
MID SEM-I
Process control block (PCB) is a data structure which is associated with any
process and provides all the complete information about that process. The process
control block is "the manifestation of a process in an operating system". Process
3
The following are the various components that are associated with the process
control block PCB:
1. Process ID:
In computer system there are various process running simultaneously and each
process has its unique ID. This Id helps system in scheduling the processes. This Id
is provided by the process control block.
In other words, it is an identification number that uniquely identifies the processes
of computer system.
2. Process state:
As we know that the process state of any process can be New, running, waiting,
executing, blocked, suspended, terminated. For more details regarding process
states you can refer process management of an Operating System.
Process control block is used to define the process state of any process.
In other words, process control block refers the states of the processes.
3. Program counter:
Program counter is used to point to the address of the next instruction to be
executed in any process. This is also managed by the process control block.
4. Register Information:
This information is comprising with the various registers, such as index and stack
that are associated with the process. This information is also managed by the
process control block.
5. Scheduling information:
Scheduling information is used to set the priority of different processes. This is
very useful information which is set by the process control block. In computer
system there were many processes running simultaneously and each process have
its priority. The priority of primary feature of RAM is higher than other secondary
features. Scheduling information is very useful in managing any computer system.
4
7. Accounting information:
This section of process control block stores the details relate to central processing
unit (CPU) utilization and execution time of a process.
The operating system maintains a table called process table, which stores the
process control blocks related to all the processes.
Answer- Spinlocks are not appropriate for single processor systems because the
condition that would break a process out of the spinlock can be obtained only by
executing a different process.If the process is not relinquishing the processor, other
process don’t get the opportunity to set the program condition required for the first
process to progress. In a multiprocessor system,other processes execute on other
processors and thereby modify the program state inorder to release the first process
from spinlock.
Question-5) Explain the various classical problems of synchronization?
Classical Problems of Synchronization-
In this tutorial we will discuss about various classic problem of synchronization.
Semaphore can be used in other synchronization problems besides Mutual
Exclusion.
Below are some of the classical problem depicting flaws of process
synchronaization in systems where cooperating processes are present.
We will discuss the following three problems:
Solution to this problem is, creating two counting semaphores "full" and
"empty" to keep track of the current number of full and empty buffers
respectively.
The Readers Writers Problem-
In this problem there are some processes(called readers) that only read the
shared data, and never change it, and there are other processes(called writers)
who may change the data in addition to reading, or instead of reading it.
There are various type of readers-writers problem, most centred on relative
priorities of readers and writers.
Dining Philosophers Problem-
MID SEM-∏
SET- A
Question-1) What is CPU state? Explain how the notion of the CPU state is
useful in implementing multiprogramming?
Ans:- CPU state- It refers to the CPU modes or CPU scheduling modes. In this
state the process coming from ready state are executed by CPU. The scheduler
used here is short term scheduler which carries the process from ready state to
running state so CPU state can also be called as running state of process.
6
The CPU state helps in the concept of multiprogramming as the CPU can execute
many process with some time quantum in multitasking or one by one in
multiprogramming. The CPU can handle many process and hence helps in
multiprogramming.
Question-2) Out of Multiprogramming & Time sharing operating system
which one is having maximum CPU utilization & which one has maximum
user response and why? Can you categorize batch processing as the king of
multiprogramming?
Ans:-Multiprogramming is the allocation of more than one concurrent program on
a computer system and its resources. Multiprogramming allows using the CPU
effectively by allowing various users to use the CPU and I/O devices effectively.
Multiprogramming makes sure that the CPU always has something to execute, thus
increases the CPU utilization. On the other hand, Time sharing is the sharing of
computing resources among several users at the same time. Since this will allow a
large number of users to work in a single computer system at the same time, it
would lower the cost of providing computing capabilities. Hence allow maximum
user response.
Yes we can categorize the batch OS as the king operating system as when it is
added with multiprogramming facilities.
Question-3) What are the advantages of inter – process communication? How
communication takes place in shared memory environment? Explain
Ans:- Process to Process Communication: The unit of transfer in this layer is the
UDP datagram, and the destination is an input port within a host. Thus, the
destination of a message is specified as the pair.
Inter process communication messages mimic the reading and writing of files.
They are easier to use than pipes when more than
two process must communicate by using a single medium. Shared memory is the
fastest form of interprocess communication. The main advantage of shared
memory is that the copying of message data is eliminated. This allows a program
to handle many user requests at the same time.
Question-4) What are the necessary conditions for a deadlock?
Ans:- Deadlock Conditions are as follows:-
resources were requested, deadlock could not occur because the process
would not prevent others from using resources that it controlled.
3. No pre-emption:- The processes must not have resources taken away while
that resource is being used. Otherwise, deadlock could not occur since the
operating system could simply take enough resources from running
processes to enable any process to finish.
4. Resource waiting or circular wait:- A circular chain of processes, with each
process holding resources which are currently being requested by the next
process in the chain, cannot exist. If it does, the cycle theorem (which states
that "a cycle in the resource graph is necessary for deadlock to occur")
indicated that deadlock could occur.
Question-5) What is process? Explain about various fields of Process Control
Block?
Ans:- Process:- A program under execution is called process. Or we can say that a
program in running state is called process.
The various fields of process control block are as under:-
1) Process state:- This tells us about different state of process. Like ready state,
running state, block state etc…
2) Process Id:- Every process has some unique Id. This field tell about the id
number of process.
3) Program counter:- This is a register which keeps the address of the next
instruction to be executed
4) Registers:- These are the temporary storage for different process in running
state.
5) Memory management :- These control the memory of the process.
Queastion-6) What is critical section problem? Give the condition that a
solution to the critical section problem must satisfy?
Ans:- In concurrent programming, concurrent accesses to shared resources can lead
to unexpected or erroneous behavior, so parts of the program where the shared
resource is accessed are protected. This protected section is the critical section or
critical region. It cannot be executed by more than one process.
SET-B
Sharing the processor, when two or more programs reside in memory at the same
time, is referred as multiprogramming. Multiprogramming assumes a single
shared processor. Multiprogramming increases CPU utilization by organizing jobs
so that the CPU always has one to execute.
The following figure shows the memory layout for a multiprogramming system.
An OS does the following activities related to multiprogramming.
The operating system keeps several jobs in memory at a time.
This set of jobs is a subset of the jobs kept in the job pool.
The operating system picks and begins to execute one of the jobs in the
memory.
Multiprogramming operating systems monitor the state of all active
programs and system resources using memory management programs to
ensures that the CPU is never idle, unless there are no jobs to process.
Advantages
CPU scheduling is required.
To accommodate many jobs in memory, memory management is required.
The eating arrangements are as follows: a round table as above where five plates of
spaghetti are kept for each philosopher and five forks.
A philosopher who wishes to eat goes to his/her assigned place on the table
and eats the spaghetti plate in front of him using the two forks before him.
The Aim of the Dinging philosopher’s problem is to allow all the
philosophers to eat.
It must also satisfy the principles of mutual exclusion (no two philosophers
can use the same fork at the same time) while avoiding deadlock and
starvation.
Error handling code is not needed unless that specific error occurs, some of
which are quite rare.
Arrays are often over-sized for worst-case scenarios, and only a small
fraction of the arrays are actually used in practice.
Certain features of certain programs are rarely used.
Backup- or the process of backing up, refers to the copying
and archiving of computer data so it may be used to restore the original
after a data lossevent. Backups have two distinct purposes. The primary
purpose is to recover data after its loss, be it by data
deletion or corruption.The secondary purpose of backups is to recover
data from an earlier time, according to a user-defined data
retention policy, typically configured within a backup application for how
long copies of data are required. Though backups represent a simple form
of disaster recovery, and should be part of any disaster recovery plan,
backups by themselves should not be considered a complete disaster
recovery plan.
The difference between the creation of thread and a process is a thread is smaller
than a process, thread creation typically uses fewer resources than process creation.
Creating a process requires allocating a process control block (PCB), a rather large
data structure.
more processes, so “one” process cannot hold a resource, yet be waiting for
another resource that it is holding.