0% found this document useful (0 votes)
7 views

OS Final PDF

Imp for osy

Uploaded by

aryannnborse2k5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

OS Final PDF

Imp for osy

Uploaded by

aryannnborse2k5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1. Define real time operating system. List its any four applications of it.

 The real-time operating system used for a real-time application means for those applications where data processing
should be done in the fixed and small quantum of time. Applications:
Types of real time operating system
1. Flight Control System 2. Simulations
1. Hard real-time
3. Industrial control 4. Military applications
2. Soft real-time

2. Explain any 4 services provided by OS.


1.User Interface: All operating systems have a user interface that allows users to communicate with the system.
Three types of user interfaces are available:
a. Command line interface (CLI) b. Batch interface c. Graphical user interface (GUI)
2. I/O operations: When a program is running, it may require input/output resources such as a file or devices such as
printer. So the operating system provides a service to do I/O.
3. Error detection: Operating systems detects CPU and memory hardware such as a memory error or power failure, a
connection failure on a network or lack of paper in the printer etc.
4.Resource allocation: Operating system manages resource allocation to the processes. These resources are CPU,
main memory, file storage and I/O devices.
5.Accounting: Operating system keeps track of usages of various computer resources allocated to users.

3.Define Virtual Memory


Virtual memory is a memory management capability of an operating system (OS) that uses hardware and software
to allow a computer to compensate for physical memory shortages by temporarily transferring data from random
access memory (RAM) to disk storage.

4. Describe different scheduling criteria.


CPU utilization: - In multiprogramming the main objective is to keep CPU as busy as possible. CPU utilization can
range from 0 to 100 percent. Throughput: - It is the number of processes that are completed per unit time. It is a
measure of work done in the system. When CPU is busy in executing processes, then work is being done in the
system. Throughput depends on the execution time required for any process. Turnaround time: -The time interval
from the time of submission of a process to the time of completion of that process is called as turnaround time. It is the
sum of time period spent waiting to get into the memory, waiting in the ready queue, executing with the CPU, and
doing I/O operations. Waiting time: - It is the sum of time periods spent in the ready queue by a process. When a
process is selected from job pool, it is loaded into the main memory. A process waits in ready queue till CPU is
allocated to it

5. Draw and explain process state diagram


New: When a process enters into the system, it is in new state. In this state a process is created. In new state the
process is in job pool. Ready: When the process is loaded into the main memory, it is ready for execution. In this state
the process is waiting for processor allocation. Running: When CPU is available, system selects one process from
main memory and executes all the instructions from that process. So, when a process is in execution, it is in running
state. In single user system, only one process can be in the running state. In multiuser system, there can be multiple
processes which are in the running state. Waiting State: When a process is in execution, it may request for I/O
resources. If the resource is not available, process goes into the waiting state. When the resource is available, the
process goes back to ready state. Terminated State: When the process completes its execution, it goes into the
terminated state. In this state the memory occupied by the process is released.
1.With neat diagram explain inter process communication model.
Inter-process communication: Cooperating processes require an Inter process communication (IPC) mechanism that
will allow them to exchange data and information.
There are two models of IPC 1. Shared memory:- i) In this, all processes who want to communicate with other
processes can access a region of the memory residing in an address space of a process creating a shared memory
segment. ii)All the processes using the shared memory segment should attach to the address space of the shared
memory. All the processes can exchange information by reading and/or writing data in shared memory segment. Iii)
The form of data and location are determined by these processes who want to communicate with each other. iv) These
processes are not under the control of the operating system. v) The processes are also responsible for ensuring that
they are not writing to the same location simultaneously. vi)After establishing shared memory segment, all accesses
to the shared memory segment are treated as routine memory access and without assistance of kernel.
2.Message Passing:- i) In this model, communication takes place by exchanging messages between cooperating
processes. ii) It allows processes to communicate and synchronize their action without sharing the same address
space. iii) It is particularly useful in a distributed environment when communication process may reside on a
different computer connected by a network. iv) Communication requires sending and receiving messages through the
kernel.v)The processes that want to communicate with each other must have a communication link between them.
Between each pair of processes exactly one communication link

2.Describe I/O Burst and CPU Burst cycle with neat diagram.
CPU burst cycle: It is a time period when process is busy with CPU. I/O burst cycle: It is a time period when process
is busy in working with I/O resources.
i) A process execution consists of a cycle of CPU execution and I/O wait. ii) A process starts its execution when CPU
is assigned to it, so process execution begins with a CPU burst cycle. iii) This is followed by an I/O burst cycle when
a process is busy doing I/O operations. Iv) A process switch frequently from CPU burst cycle to I/O burst cycle and
vice versa. V) The complete execution of a process starts with CPU burst cycle, followed by I/O burst cycle, then
followed by another CPU burst cycle, then followed by another I/O burst cycle and so on. Vi) The final CPU burst
cycle ends with a system request to terminate execution.

3. Explain deadlock? What are necessary conditions for deadlock?


A Deadlock is a situation where each of the computer process waits for a resource which is being assigned to some
another process. In this situation, none of the process gets executed since the resource it needs, is held by some other
process which is also waiting for some other resource to be released.
Necessary conditions for Deadlock: 1. Mutual Exclusion: A resource can only be shared in mutually exclusive
manner. It implies, if two process cannot use the same resource at the same time. 2. Hold And wait: If one process
holding a resource and waiting for another resource that is held by another process. Then it leads to a deadlock. 3.
Circular wait: All the processes must be waiting for the resources in a cyclic manner so that the last process is
waiting for the resource which is being held by the first process. 4. No preemption: The process which once
scheduled will be executed till the completion. No other process can be scheduled by the scheduler meanwhile.

4.Explain partitioning and its types


Partitioning is a technique that divides a memory into multiple partitions. These partitions can be of different size or
same size. Types of partitioning 1)Fixed partitioning 2)Variable partitioning i) Fixed Partitioning: Main
memory is divided into multiple partitions of fixed size at the time of system generation. A process may be loaded into
a partition of equal size or greater size. Partitions can be of equal size or unequal size Equal size partitioning: Main
memory is divided into equal size partitions. Any process with less or equal size can be loaded in any available
partition.
Variable partitioning: When a process enters in main memory, it is allocated exact size that is required by that
process. So in this method, partitions can vary in size depending on memory space required by a process entering in
main memory. Operating system maintains a table indicating which parts of memory are available and which are
occupied. When new process arrives and it needs space, system searches for available memory space in main memory.
If it is available, then memory is allocated to the process by creating a partition in memory. For example: Consider
following table with process and memory space.
1.Describe sequential and direct access method.
Sequential access: Information from the file is processed in order i.e. one record after another. It is commonly used
access mode. For example, editors and compilers access files in sequence. A read operation read information from the
file in a sequence i.e. read next reads the next portion of the file and automatically advances a file pointer. A write
operation writes information into the file in a sequence i.e. write next appends to the end of the file and advances to
the end of the newly written material. Such a file can be reset to the beginning. In some operating systems, a program
may be able to skip forward or backward n records for some integer n
Direct access: It is also called as relative access. A file is made up of fixed length logical records that allow programs
to read and write records rapidly in no particular order. Direct access method is based on disk model of a file which
allows random access to any file block. For direct access a file is viewed as a numbered sequence of blocks or records.
So we can directly read block 14, then block 53 and so on. This method is used for immediate access to large amount
of information. Database can be accessed with direct access method. For example, when a query concerning a
particular subject arrives, we compute which block contains the answer and then read that block directly to provide the
desired information. Read n operation is used to read the nth block from the file whereas write n is used to write in
that block. The block numbers provided by the user to the operating system is a relative block number. A relative
block number is an index relative to the beginning of the file. The first relative block of file is 0; the next is 1 and so
on. Actual absolute disk address of the block is different from the relative address. The use of relative block numbers
allow the operating system to decide where the file should be placed and helps t prevent the user from accessing
portions of the file system that may not be part of his file.

2. What is purpose of system call? State two system calls with their functions.
System call provides an interface between a running program and operating system. It allows user to access services
provided by operating system. This system calls are procedures written using C, C++ and assembly language
instructions. Each operating system has its own name for each system call. Each system call is associated with a
number that identifies itself. System calls: Process Control: Program in execution is a process. A process to be
executed must be loaded in main memory. while executing it may need to wait, terminate or create & terminate child
processes. end, abort load, execute create process, terminate process get process attributes, set process
attributes wait for time wait event, signal event allocate and free memory
Device Management: When a process is in running state, it requires several resources to execute. These resources
include main memory, disk drives, files and so on. If the resource is available, it is assigned to the process. Once the
resource is allocated to the process, process can read, write and reposition the device.  request device, release device
read, write, reposition get device attributes, set device attributes logically attach or detach devices

3.State and describe types of scheduler.


1. Long term scheduler: It selects programs from job pool and loads them into the main memory. It controls the
degree of multiprogramming. The degree of multiprogramming is the number of processes loaded (existing) into the
main memory. System contains I/O bound processes and CPU bound processes. An I/O bound process spends more
time for doing I/O operations whereas CPU bound process spends more time in doing computations with the CPU. So
It is the responsibility of long term scheduler to balance the system by loading some I/O bound and some CPU bound
processed into the main memory. Long term scheduler executes only when a process leaves the system, so it executes
less frequently. When long term scheduler selects a process from job pool, the state of process changes from new to
ready state. 2. Short term scheduler: It is also known as CPU scheduler. This scheduler selects processes that are
ready for execution from the ready queue and allocates the CPU to the selected process. Frequency of execution of
short term scheduler is more than other schedulers. When short term scheduler selects a process, the state of process
changes from ready to running state. 3.Medium term scheduler: When a process is in running state, due to some
interrupt it is blocked. System swaps out blocked process and store it into a blocked and swapped out process queue.
When space is available in the main memory, the operating system looks at the list of swapped out but ready
processes. The medium term scheduler selects one process from that list and loads it into the ready queue. The job of
medium term scheduler is to select a process from swapped out process queue and to load it into the main memory.
This scheduler works in close communication with long term scheduler for loading process into the main memory.
1.Explain Round Robin algorithm
It is preemptive scheduling algorithm. A small unit of time known as a time quantum or time slice is used for pre-
emption of a currently running process. Ready queue is implemented as a circular queue. CPU is assigned to the entire
processes one by one, on first come first serve basis, for a specific time period. Every process executes for specified
time period and CPU is given to the next process when time quantum expires. A new process is added at the tail of the
ready queue when it enters the system. CPU scheduler selects first process from head of the ready queue and executes
it for a specified time quantum. Once the time quantum expires, dispatcher is invoked to pre-empt current running
process and CPU is given to the next process placed at the head of the ready queue. The running process may have a
CPU burst time less or greater than time quantum. If burst time of running process is less than the time quantum then,
the process itself releases the CPU. The scheduler then selects next process from ready queue and executes it. If burst
time of running process is longer than time quantum then, context switch occurs and the process is place at the tail of
ready queue for remaining burst time execution.

2. Explain PCB with diagram


Each process is represented as a process control block (PCB) in the operating system. It contains information
associated with specific process. Process State: It indicates current state of a process. Process state can be new, ready,
running, waiting and terminated. Process number: Each process is associated with a unique number which is known
process identification number. Program Counter: It indicates the address of the next instruction to be executed for
the process. CPU Registers: The registers vary in number and type depending on the computer architecture. Register
includes accumulators, index registers, stack pointers and general purpose registers plus any condition code
information. Memory Management Information: It includes information such as value of base and limit registers,
page tables, segment tables, depending on the memory system used by OS. Accounting Information: This
information includes the amount of CPU used, time limits, account holders, job or process number and so on. It also
includes information about listed I/O devices allocated to the process such as list of open files. Each PCB gives
information about a particular process for which it is designed.

3.Enlist the operating system tools. Explain any two in detail.


Following are the operating tools:
User Management Security policy Device Management Performance Monitor Task Scheduler
A) User management:
 User management includes everything from creating a user to deleting a user on your system. User management can
be done in three ways on a Linux system.
Command line tools include commands like useradd, userdel, usermod, passwd, etc. These are mostly used by the
server administrators.
Useradd: With useradd commands you can add a user. Userdel: To delete a user account userdel command
Syntax: useradd -m -d /home/<userName> - is used.
c "<userName>" <userName> Syntax: userdel -r <userName>
Example: useradd -m -d /home/xyz -c "xyz" xyz
File /etc/default/useradd contains some user default options. Using passwd command
The command useradd -D can be used to display this file. Passwd: A user can set the password
Syntax: useradd -D with the command passwd. Old
Usermod: The command usermod is used to modify the properties of password has to be typed twice before
an existing user. entering the new one.
Syntax: usermod -c <'newName'> <oldName> Syntax: passwd <userName>
Example: usermod -c 'vppoly' john Example: passwd vppoly
B) Device Management: Device management is the process of managing the implementation, operation and
maintenance of a physical and/or virtual device. All Linux device files are located in the /dev directory, which is an
integral part of the root (/) filesystem because these device files must be available to the operating system during the
boot process. Example: ls –l /dev Above example gives the list of device file from kernel. Udev supplies a dynamic
device directory containing only the nodes for devices which are connected to the system. It creates or removes the
device node files in the /dev directory
1.Explain multithreading model in detail.
Many to one Multithreading model: The many-to-one model maps many user-level threads to one kernel thread.
Thread management is done by the thread library in user space,so it is efficient. However, the entire process will block
if a thread makes a blocking system call. Also, because only one thread can access the kernel at a time, multiple
threads are unable to run in parallel on multicore systems.
One to one Multithreading Model: The one-to-one model maps a single user-level thread to a single kernel-level
thread. This type of relationship facilitates the running of multiple threads in parallel. However, this benefit comes
with its drawback.
Many to many Multithreading Model: In this type of model, there are several user-level threads and several kernel-
level threads. The number of kernel threads created depends upon a particular application. The developer can create as
many threads at both levels but may not be the same. The many to many model is a compromise between the other
two models. In this model, if any thread makes a blocking system call, the kernel can schedule another thread for
execution. Also, with the introduction of multiple threads, complexity is not present as in the previous models. Though
this model allows the creation of multiple kernel threads, true concurrency cannot be achieved by this model. This is
because the kernel can schedule only one process at a time.

2.Describe free space management technique.


A file system is responsible to allocate the free blocks to the file therefore it has to keep track of all the free blocks
present in the disk.There are mainly four approaches by using which, the free blocks in the disk are managed.
1.Bit Vector 2. Linked List
2) Linked List:- In this approach, the free disk blocks are linked together i.e. a free block contains a pointer to the
next free block. The block number of the very first disk block is stored at a separate location on disk and is also
cached in memory. In this approach, link all the disk blocks together, keeping a pointer to the first free block. This
block contains a pointer to the next free disk block, and so on.

3.Enlist different file allocation methods? Explain contiguous allocation method in detail.
Three major methods of allocating disk space are in wide use: Contiguous Linked Indexed
Contiguous Allocation • The contiguous allocation method requires each file to occupy a set of contiguous addresses
on the disk. Disk addresses define a linear ordering on the disk. Contiguous allocation of a file is defined by the disk
address of the first block and its length. If the file is ‘n’ blocks long and starts at location ‘b’, then it occupies blocks b,
b+1, b+2, - - - - - b+n-1. The directory entry for each file indicates the address of the starting block and the length of
the area allocated for this file. • Contiguous allocation supports both sequential and direct access. • For direct access
to block ‘i’ of a file, which starts at block ‘b’, we can immediately access block b+i. The difficulty with contiguous
allocation is finding space for a new file. • For direct access to block ‘i’ of a file, which starts at block ‘b’, we can
immediately access block b+i. • The difficulty with contiguous allocation is finding space for a new file. • If file to be
created are ‘n’ blocks long, we must search free space list for ‘n’ free contiguous blocks.
Advantages of Contiguous File Allocation Method: 1. Supports both sequential and direct access methods. 2.
Contiguous allocation is the best form of allocation for sequential files. Multiple blocks can be brought in at a time to
improve I/O performance for sequential processing. 3. It is also easy to retrieve a single block from a file. For
example, if a file starts at block ‘n’ and the ith block of the file is wanted, its location on secondary storage is simply n
+ i. 4. Reading all blocks belonging to each file is very fast. 5. Provides good performance.
Disadvantages of Contiguous File Allocation Method: 1. Suffers from external fragmentation. 2. Very difficult to
find contiguous blocks of space for new files.

Define : Process, PCB


Process:-A process is a program in execution. Process is also called as job, task or unit of work.
PCB:-Process Control Block is a data structure that contains information of the process related to it. The process
control block is also known as a task control block, entry of the process table, etc.
1.Explain Time sharing O.S.
In time sharing system, the CPU executes multiple jobs by switching among them. The switches occur so frequently
that the users can interact with each program while it is running. It includes an interactive computer system which
provides direct communication between the user and the system. A time-sharing system allows many users to share
the computer resources simultaneously. The timesharing system provides the direct access to many users where CPU
time is divided among all the users on scheduled basis. The operating system allocates a time slice to each user. When
this time is expired, it passes control to the next user on the system. The time allowed is extremely small and the users
are given the impression that each of them has their own CPU and they are the sole owner of the CPU. In this time
slice each user gets attention of the CPU. The objective of time-sharing system is to minimize response time of
process.

2.Describe any two components of O.S.


1. Process management 2. Main memory management 3. File management 4. I/O system management 5. Secondary
storage management
1.Process Management: A program is a set of instructions. When CPU is allocated to a program, it can start its
execution. A program in execution is a process. A word processing program run by a user on a PC is a process. A
process needs various system resources including CPU time, memory, files and I/O devices to complete the job
execution. These resources can be given to the process when it is created or allocated to it while it is running.
The operating system responsible for the following activities in connection with process management: Creation and
deletion of user and system processes. Suspension and resumption of processes. A mechanism for process
synchronization. A mechanism for process communication. A mechanism for deadlock handling.
2. I/O device Management: Input / Output device management provides an environment for the better interaction
between system and the I / O devices (such as printers, scanners, tape drives etc.). To interact with I/O devices in an
effective manner, the operating system uses some special programs known as device driver. The device drivers take
the data that operating system has defined as a file and then translate them into streams of bits or a series of laser
pulses (in regard with laser printer). The I/O subsystem consists of several components:  A memory management
component that includes buffering, caching, spooling A general device driver interface Drivers for specific
hardware devices

3. Describe conditions for deadlock prevention.


1.Mutual Exclusion: The mutual-exclusion condition must hold for non-sharable resources. Sharable resources do not
require mutually exclusive access, thus cannot be involved in a deadlock. 2.Hold and Wait: One way to avoid this
Hold and Wait is when a process requests a resource; it does not hold any other resources. One protocol that can be
used requires each process to request and be allocated all its resources before it begins execution. Another protocol
that can be used is, to allow a process to request resources only when the process has none. A process may request
some resources and use them. Before it requests any additional resources, it must release all the resources that are
currently allocated to it. 3.No Preemption: If a process that is holding some resources requests another resource that
cannot be immediately allocated to it, then all resources currently being held are preempted. That is these resources
are implicitly released. The preempted resources are added to the list of resources for which the process is waiting.
Process will be restarted only when all the resources i.e. its old resources, as well as the new ones that it is requesting
will be available. 4.Circular Wait:- Circular-wait condition never holds is to impose a total ordering of all resource
types, and to require that each process requests resources in an increasing order of enumeration. Let R = {R1, R2, ...,
Rn} be the set of resource types. We assign to each resource type a unique integer number, which allows us to
compare two resources and to determine whether one precedes another in our ordering. Formally, define a one-to-one
function F: R _ N, where N is the set of natural numbers.
1.Explain fixed size memory partitioning.
Fixed Size Memory Partitioning (Static)  Memory is divided into number of fixed size partitions, which is called as
fixed or static memory partitioning. Each partition contains exactly one process.  The number of programs to be
executed depends on number of partitions.  When the partition is free, a selected process from the input queue is
loaded into the free partition.  When the process terminates, the partition becomes available for another process.
The operating system keeps a table indicating parts of memory which are available and which are occupied.
Initially, all memory is available for user processes and it is considered as one large block of available memory, a
hole.  When a process arrives, large enough hole of memory is allocated to the processes.

2.Explain linked file allocation method.


Linked Allocation: This allocation is on the basis of an individual block. Each block contains a pointer to the next
block in the chain.  The disk block can be scattered anywhere on the disk The directory contains a pointer to the
first and the last blocks of the file.  To create a new file, simply create a new entry in the directory. The following
figure shows the linked allocation. There is no external fragmentation since only one block is needed at a time. The
size of a file need not be declared when it is created.  A file can continue to grow as long as free blocks are available
 This method is used only for a sequential access files This method requires more space to store pointers  So
instead of blocks, clusters are used for allocation but this creates internal fragmentation

3.Write any four systems call related to file management.


System calls related to file management are: 1. create new file 2. delete existing file 3. open file 4. close file 5. create
directories 6. delete directories 7. read, write, reposition in file 8. getfile attributes 9. set file attributes

4.Writer the outputs of following commands


(i) Wait 2385018 (ii) Sleep 09 (iii) PS –u Asha
i) Wait command waits until the termination of specified process ID 2385018
ii) Sleep command is used to delay for 9 seconds during the execution of a processi.e. it will pause the terminal for 9
seconds.
iii) ps command with -u is used to display data/processes for the specific user Asha.

5.Write two uses of following O.S. tools (i) Device Management (ii) Performance monitor (iii) Task Scheduler
i) Device management:  Managing all the hardware or virtual devices of computer system. Allow interaction
with hardware devices through device driver. Used to install device and component-level drivers as well as
associated software. Allocate devices to the process as per process requirement and priority.  Deallocate devices
either temporarily or permanently dependingon condition.  Keeping track of all device’s data and location.
Monitoring device status like printers, storage drivers and other devices.  Used to enforce the predetermined
policies and decides which process receives the device when and for how long. ii) Performance monitor 1. Monitor
various activities on a computer such as CPU or memory usage. 2. Used to examine how programs running on their
computer affect computer’s performance 3. It is used to identify performance problems or bottleneck that affect
operating system or installed applications. 4. Used to observe the effect of system configuration changes.
iii) Task scheduler 1. Assign processor to task ready for execution 2. Executing predefined actions automatically
whenever a certain set of condition is met.

You might also like