Explain Functions of Operating System (5M) Functions of An Operating System Memory Management
Explain Functions of Operating System (5M) Functions of An Operating System Memory Management
Memory Management
It keeps track of primary memory, i.e., which bytes of memory are used by
which user program. The memory addresses that have already been allocated and
the memory addresses of the memory that has not yet been used.
In multiprogramming, the OS decides the order in which processes are granted
memory access, and for how long.
It Allocates the memory to a process when the process requests it and
deallocates the memory when the process has terminated or is performing an I/O
operation.
Processor Management
Device Management
File Management
A file system is organized into directories for efficient or easy navigation and usage.
These directories may contain other directories and other files. An Operating System
carries out the following file management activities. It keeps track of where information
is stored, user access settings, the status of every file, and more. These facilities are
collectively known as the file system.
Job Accounting
The operating system Keeps track of time and resources used by various tasks and
users, this information can be used to track resource usage for a particular user or
group of users.
Resource Allocation:
The Operating System ensures the proper use of all the resources available by
deciding which resource to be used by whom for how much time. All the decisions are
taken by the Operating System.
Accounting:
The Operating System tracks an account of all the functionalities taking place in
the computer system at a time. All the details such as the types of errors that occurred
are recorded by the Operating System.
System Services:
The operating system provides various system services, such as printing, time
and date management, and event logging.
Process state – It stores the respective state of the process, i.e. new, ready,
running, waiting or terminated.
Process number – Every process is assigned with a unique id known as
process ID or PID which stores the process identifier.
This shows particular No. of Processess
Program counter – It stores the counter which contains the address of the
next instruction that is to be executed for the process.
Register – These are the CPU registers which includes: accumulator, base,
registers and general purpose registers.
This specifies the register that are used by the process.
Memory limits – This field contains the information about memory
management system used by operating system. This may include the page tables,
segment tables etc.
Open files list – This information includes the list of files opened for a
process.
1. CPU Scheduling Information
2. Memeory Management Information
3. Input Output Status Information
4. Accounting Information
File management:
This system call is responsible for file manipulations such as create file, open file,
close file, delete file, read files, etc.
Device management
This system call is responsible for device manipulations such as writing into
devices, reading from devices, etc.
Information maintenance
This system call handle information and transferance between OS and User
Program.
Communication
This system call are useful for interprocess communication. They also deal with
creating and deleting a connection.
6. Consider the given table below and find Completion time (CT),
Turn-around time (TAT), Waiting time (WT), Response time (RT),
Average Turn-around time and Average Waiting time by using FCFS
algorithm.
Process ID Arrival Time Burst Time
P1 2 2
P2 5 6
P3 0 4
P4 0 7
P5 7 4
[5M
7. What is Inter Proess Commumication (IPC). Explain any one
classical problem of synchronization. [8M]
A process can be of two types:
Independent process.
Co-operating process.
There are two versions of this problem: the first one is known as the unbounded
buffer problem in which the Producer can keep on producing items and there is no limit
on the size of the buffer, the second one is known as the bounded buffer problem in
which the Producer can produce up to a certain number of items before it starts
waiting for Consumer to consume it. We will discuss the bounded buffer problem. First,
the Producer and the Consumer will share some common memory, then the producer
will start producing items.
If the total produced item is equal to the size of the buffer, the producer will wait
to get it consumed by the Consumer. Similarly, the consumer will first check for the
availability of the item. If no item is available, the Consumer will wait for the Producer to
produce it. If there are items available, Consumer will consume them.
Start exchanging messages using basic primitives. We need at least two primitives:
– send(message, destination) or send(message)
– receive(message, host) or receive(message)
8. Write short note on: a) Critical Section b) Semaphore [7M]
a) Critical Section:-
When more than one processes try to access the same code segment that
segment is known as the critical section. The critical section contains shared variables
or resources which are needed to be synchronized to maintain the consistency of data
variables.
b) Semaphores
Semaphores are compound data types with two fields one is a Non-
negative integer S.V and the second is Set of processes in a queue S.L. It is used to
solve critical section problems, and by using two atomic operations, it will be solved. In
this, wait and signal that is used for process synchronization.
Semaphores are used to implement critical sections, which are regions of code
that must be executed by only one process at a time. By using semaphores, processes
can coordinate access to shared resources, such as shared memory or I/O devices.
Semaphores are of two types:
1. Binary Semaphore –
This is also known as a mutex lock. It can have only two values – 0 and 1.
Its value is initialized to 1. It is used to implement the solution of critical section
problems with multiple processes.
2. Counting Semaphore –
Its value can range over an unrestricted domain. It is used to control
access to a resource that has multiple instances.
4 3 3 R1 R2 R3
7 2 4 2 1 1
4 2 5 7 2 3
5 3 3 3 2 2
1 1 3
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.
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.
Paging makes use of a set web page length, which is usually identical to the
size of a frame within the most important memory. This facilitates to simplify the
reminiscence control technique and improves device performance.
Each page within the logical address area of a method is represented through a
page table entry (PTE), which contains facts approximately the corresponding
bodily body in the predominant memory. This consists of the frame range, in addition
to other manipulate bits which can be used by the running machine to
manage the reminiscence.
4. Number of page desk entries:
The range of page desk entries in a manner’s page desk is identical to the wide
variety of pages inside the logical deal with area of the technique.
b) Semgentation
A process is divided into Segments. The chunks that a program is divided into which
are not necessarily all of the same sizes are called segments. Segmentation gives the
user’s view of the process which paging does not give. Here the user’s view is mapped
to physical memory. There are types of segmentation:
Advantages of Segmentation –
No Internal fragmentation.
Segment Table consumes less space in comparison to Page table in paging.
As a complete module is loaded all at once, segmentation improves CPU
utilization.
The user’s perception of physical memory is quite similar to segmentation.
Users can divide user programs into modules via segmentation. These modules
are nothing more than the separate processes’ codes.
The user specifies the segment size, whereas in paging, the hardware
determines the page size.
Segmentation is a method that can be used to segregate data from security
operations.
Flexibility: Segmentation provides a higher degree of flexibility than paging.
Segments can be of variable size, and processes can be designed to have multiple
segments, allowing for more fine-grained memory allocation.
Sharing: Segmentation allows for sharing of memory segments between
processes. This can be useful for inter-process communication or for sharing code
libraries.
Protection: Segmentation provides a level of protection between segments,
preventing one process from accessing or modifying another process’s memory
segment. This can help increase the security and stability of the system.
13. Explain Contiguous and non-contiguous Memory allocation
It is of five types:
It is of two types: 1. Paging
9. 2. Multilevel Paging
1. Fixed(or static) partitioning
3. Inverted Paging
2. Dynamic partitioning
4. Segmentation
5. Segmented Paging
Memory Allocation
To gain proper memory utilization, memory allocation must be allocated efficient
manner. One of the simplest methods for allocating memory is to divide memory into
several fixed-sized partitions and each partition contains exactly one process. Thus,
the degree of multiprogramming is obtained by the number of partitions.
Multiple partition allocation:
In this method, a process is selected from the input queue and loaded into the
free partition. When the process terminates, the partition becomes available for other
processes.
Fixed partition allocation:
In this method, the operating system maintains a table that indicates which parts
of memory are available and which are occupied by processes. Initially, all memory is
available for user processes and is considered one large block of available memory.
This available memory is known as a “Hole”. When the process arrives and needs
memory, we search for a hole that is large enough to store this process. If the
requirement is fulfilled then we allocate memory to process, otherwise keeping the rest
available to satisfy future requests. While allocating a memory sometimes dynamic
storage allocation problems occur, which concerns how to satisfy a request of size n
from a list of free holes.
2. Least Recently Used: In this algorithm, page will be replaced which is least
recently used.
Initially, all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4
Page faults
0 is already their so —> 0 Page fault. when 3 came it will take the place of 7 because it
is least recently used —>1 Page fault
0 is already in memory so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault
Now for the further page reference string —> 0 Page fault because they are already
available in the memory.
Initially, all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4
Page faults
0 is already there so —> 0 Page fault. when 3 came it will take the place of 7 because it
is not used for the longest duration of time in the future.—>1 Page fault. 0 is already
there so —> 0 Page fault. 4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are already
available in the memory.
16. Given memory partitions of 100K, 500K, 200K, 300K, and 600K (in
order), how would each of the First-fit, Best-fit, and Worst-fit
algorithms place processes of 212K, 417K, 112K, and 426K (in order)?
Which algorithm makes the most efficient use of memory?
[8M]
First-Fit:
Best-Fit:
212K is put 417K is put 112K is put 426K is put
Worst-Fit:
A buffer is a memory area that stores data being transferred between two
devices or between a device and an application.
After receiving the data in the buffer, the data get transferred to disk from buffer
in a single operation.
This process of data transfer is not instantaneous, therefore the modem needs
another buffer in order to store additional incoming data.
When the first buffer got filled, then it is requested to transfer the data to disk.
The modem then starts filling the additional incoming data in the second buffer
while the data in the first buffer getting transferred to disk.
When both the buffers completed their tasks, then the modem switches back to
the first buffer while the data from the second buffer get transferred to the disk.
The use of two buffers disintegrates the producer and the consumer of the data,
thus minimizes the time requirements between them.
Buffering also provides variations for devices that have different data transfer
sizes.
18. Explain Direct Memory Access (DMA) in detail [7M]
DMA Controller is a hardware device that allows I/O devices to directly access
memory with less participation of the processor. DMA controller needs the same old
circuits of an interface to communicate with the CPU and Input/Output devices.
Dual-Ended DMA: Dual-Ended DMA controllers can read and write from two memory
addresses. Dual-ended DMA is more advanced than single-ended DMA.
Directory Structure:-
A directory is a container that is used to contain folders and files. It organizes
files and folders in a hierarchical manner.
There are several logical structures of a directory, these are given below.
Single-level directory –
The single-level directory is the simplest directory structure. In it, all files are contained
in the same directory which makes it easy to support and understand.
A single level directory has a significant limitation, however, when the number of files
increases or when the system has more than one user. Since all the files are in the
same directory, they must have a unique name. if two users call their dataset test, then
the unique name rule violated.
Memory access methods:
These are 4 types of memory access methods:
1. Sequential Access:-
In this method, the memory is accessed in a specific linear sequential manner,
like accessing in a single Linked List. The access time depends on the location of the
data.
Applications of this sequential memory access are magnetic tapes, magnetic disk and
optical memories.
2. Random Access:
In this method, any location of the memory can be accessed randomly like
accessing in Array. Physical locations are independent in this access method.
3. Direct Access:
4. Associate Access:
In this memory, a word is accessed rather than its address. This access method
is a special type of random access method. Application of thus Associate memory
access is Cache memory.
FCFS:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is: 50
So, total overhead movement (total distance covered by the disk arm) : =(82-50)+(170-
82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16) =642
SSTF:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50
So,
total overhead movement (total distance covered by the disk arm) =(50-43)+(43-
24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170) =208
SCAN:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the
Read/Write arm is at 50, and it is also given that the disk arm should move “towards
the larger value”.
Therefore, the total overhead movement (total distance covered by the disk arm) is
calculated as:
1. =(199-50)+(199-16) =332
CSCAN:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the
Read/Write arm is at 50, and it is also given that the disk arm should move “towards
=(199-50)+(199-0)+(43-0) =391
LOOK:
1. Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the
Read/Write arm is at 50, and it is also given that the disk arm should
move “towards the larger value”.