Os Assignment
Os Assignment
Os Assignment
An Operating System (OS) is an interface between a computer user and computer hardware. An
operating system is a software which performs all the basic tasks like file management, memory
management, process management, handling input and output, and controlling peripheral devices
such as disk drives and printers.
3. What is Kernel?
Kernel is central component of an operating system that manages operations of computer and
hardware. It basically manages operations of memory and CPU time. It is core component of an
operating system
Process Thread
In computing, a page fault (sometimes called PF or hard fault) is an exception that the memory
management unit (MMU) raises when a process accesses a memory page without proper
preparations. Accessing the page requires a mapping to be added to the process's virtual address
space.
Optimal page replacement is the best page replacement algorithm as this algorithm results in the
least number of page faults. In this algorithm, the pages are replaced with the ones that will not be
used for the longest duration of time in the future.
Paging is a memory management scheme used to overcome the limitations of contiguous memory
allocation. It increases the memory space available for applications and processes by using disk space
as an extension of physical memory.
Compaction is a technique to collect all the free memory present in the form of fragments into one
large chunk of free memory, which can be used to run other processes. Compaction can be done
only when the relocation is dynamic and done at execution time.
To prevent the race conditions from occurring, you can lock shared variables, so that only one thread
at a time has access to the shared variable. Lock variable is a synchronization mechanism. It uses a
lock variable to provide the synchronization among the processes executing concurrently.
10. What is Critical Region? How do they relate to controlling access to shared resources?
In an operating system, a critical region refers to a section of code or a data structure that must be
accessed exclusively by one method or thread at a time.
Peterson's algorithm (or Peterson's solution) is a concurrent programming algorithm for mutual
exclusion that allows two or more processes to share a single-use resource without conflict, using
only shared memory for communication
For example, let int a=5, and there are two processes p1 and p2 that can modify the value of a. p1
adds 2 to a a=a+2 and p2 multiplies a with 2, a=a*2.
12. Explain first fit, best fit, next fit and worst fit in memory management.
First Fit: Allocates the first available memory block that is large enough to accommodate the
process.
Best Fit: Allocates the smallest available memory block that fits the process's size, minimizing
wasted memory.
Next Fit: Similar to First Fit but starts searching for available memory from the last allocation
point.
Worst Fit: Allocates the largest available memory block, potentially leading to more
fragmentation.
Paging is a function of memory management where a computer will store and retrieve data from a
device's secondary storage to the primary storage. The primary concept behind paging is to break
each process into individual pages. Thus the primary memory would also be separated into frames.
Segmentation is the process of dividing potential customers into groups based on similar interests or
characteristics.
15. What do you mean by Semaphores? Explain the types of Semaphores with example.
Semaphores are compound data types with two fields one is a Non-negative integer S.V. and the
second is a 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
There are two main types of semaphores i.e. counting semaphores and binary semaphores
Counting Semaphores
These are integer value semaphores and have an unrestricted value domain. These semaphores are
used to coordinate the resource access, where the semaphore count is the number of available
resources.
Binary Semaphores
The binary semaphores are like counting semaphores but their value is restricted to 0 and 1. The wait
operation only works when the semaphore is 1 and the signal operation succeeds when semaphore
is 0.
16. What is the purpose of a TLB? Explain the TLB lookup with the help of a block diagram, explaining
the hardware required.
A translation lookaside buffer (TLB) is a memory cache that stores the recent translations of virtual
memory to physical memory. It is used to reduce the time taken to access a user memory location.
TLB Lookup:
When a CPU wants to access a memory location, it first checks the TLB for a mapping.
If a mapping is not found (TLB miss), the CPU accesses the page table in main memory to find
the mapping and stores it in the TLB for future use.
17. What is meant by virtual memory? With the help of a block diagram explain the data structures
used.
Virtual Memory is a storage allocation scheme in which secondary memory can be addressed as
though it were part of the main memory.
Virtual memory is a memory management technique that uses a combination of RAM and secondary
storage (e.g., disk) to provide the illusion of a larger memory space than physically available. It uses
data structures like page tables to map virtual addresses to physical addresses.
18. What do you understand by paging? Why there is need of multilevel paging?
Paging is a function of memory management where a computer will store and retrieve data from a
device's secondary storage to the primary storage. The primary concept behind paging is to break
each process into individual pages. Thus the primary memory would also be separated into frames.
Multilevel paging extends this concept by using multiple levels of page tables to manage larger
address spaces more efficiently, reducing the memory overhead of a single-level page table.