Os Mid
Os Mid
1a) What are system calls? Briefly point out its types with illustrations. (6M)
A) System Calls:
• System calls are a programmatic way for computer programs to request services from the operating system's
kernel.
• They provide an interface between user-level processes and the operating system, allowing programs to access
hardware resources and perform privileged operations.
• These calls are generally available as assembly language instruction.
• UNIX system calls can be invoked directly from a C or C++ program.
1. Process Control
These system calls deal with process creation, termination, and management. Examples include:
• fork(): Creates a new child process
• exec(): Loads and executes a new program
• exit(): Terminates the current process
• wait(): Waits for a child process to finish
2. File Management
These system calls handle file operations such as:
• open(): Opens a file for reading or writing
• read(): Reads data from a file
• write(): Writes data to a file
• close(): Closes an open file
3. Device Management
These system calls manage device access and operations:
• ioctl(): Controls device parameters
• read()/write(): Reads from or writes to device buffers
4. Information Maintenance
These system calls handle system information:
• getpid(): Retrieves the process ID
• alarm(): Sets a timer for the process
• sleep(): Suspends process execution for a specified time
5. Communication
These system calls facilitate inter-process communication:
• pipe(): Creates a communication pipe between processes
• shmget(): Allocates shared memory segment
• socket(): Creates a network socket for communication
1b) Explain the services of the operating system that are helpful for the
user and the system. (10M)
A) Operating System Services:
Operating systems are the fundamental software that manage computer resources, provide a platform for running
applications, and interact with hardware. They act as intermediaries between users and the underlying hardware,
ensuring smooth and efficient computer operation.
Here's a detailed breakdown of the key services provided by operating systems:
1. Process Management
• Process Creation and Termination: Controls the creation and termination of processes.
• Process Scheduling: Determines the order in which processes are executed, often using algorithms like
FCFS, SJF, or priority scheduling.
• Process Synchronization: Ensures that multiple processes can coordinate their activities and avoid conflicts.
• Inter-Process Communication (IPC): Facilitates communication between processes using mechanisms like
pipes, sockets, and shared memory.
2. Memory Management
• Memory Allocation: Allocates memory to processes and data structures.
• Memory Deallocation: Frees memory that is no longer needed.
• Virtual Memory: Creates a virtual memory space for each process, allowing them to access more memory
than is physically available.
• Paging and Segmentation: Techniques used to manage virtual memory.
3. File System Management
• File Creation and Deletion: Creates and deletes files.
• File Access: Provides mechanisms for reading and writing files.
• File Organization: Organizes files into directories and subdirectories.
• File Security: Implements mechanisms to protect files from unauthorized access.
4. Input/Output (I/O) Device Management
• Device Driver Management: Loads and unloads device drivers.
• Device Access: Provides a standardized interface for accessing I/O devices.
• Buffering: Stores data in buffers to improve I/O performance.
5. Networking
• Network Protocol Implementation: Implements network protocols like TCP/IP.
• Network Connectivity: Establishes and maintains network connections.
• Network Security: Provides mechanisms to protect networks from unauthorized access and attacks.
UNIT -2
3a) With a neat diagram, explain the states of a process with a transition diagram and process control block.
(5M)
A) In an operating system, a process is a program that is being executed. During its execution, a process goes through
different states. There must be a minimum of five states.
Process States in Operating System
• New State: In this step, the process is about to be created but not yet created. It is the program that is present
in secondary memory that will be picked up by the OS to create the process.
• Ready State: After the creation of a process, the process enters the ready state i.e. the process is loaded into
the main memory. The process here is ready to run and is waiting to get the CPU time for its execution.
Processes that are ready for execution by the CPU are maintained in a queue called a ready queue for ready
processes.
• Running State: The process is chosen from the ready queue by the OS for execution and the instructions
within the process are executed by any one of the available processors.
• Blocked or Waiting State: Whenever the process requests access to I/O needs input from the user or needs
access to a critical region (the lock for which is already acquired) it enters the blocked or waits state. The
process continues to wait in the main memory and does not require CPU. Once the I/O operation is completed
the process goes to the ready state.
• Terminated or Completed State: Process is killed as well as PCB is deleted. The resources allocated to the
process will be released or deallocated.
Process Control Block (PCB)
A Process Control Block (PCB) is used by the operating system to manage information about a process. The process
control keeps track of crucial data needed to manage processes efficiently.
• Process State: The state of the process is stored in the PCB which helps
to manage the processes and schedule them. There are different states for a
process which are “running,” “waiting,” “ready,” or “terminated.”
• Process ID: The OS assigns a unique identifier to every process as soon
as it is created which is known as Process ID, this helps to distinguish
between processes.
• Program Counter: While running processes when the context switch
occurs the last instruction to be executed is stored in the program counter
which helps in resuming the execution of the process from where it left
off.
• CPU Registers: The CPU registers of the process helps to restore the state
of the process so the PCB stores a copy of them.
• Memory Information: The information like the base address or total
memory allocated to a process is stored in PCB which helps in efficient
memory allocation to the processes.
• Process Scheduling Information: The priority of the processes or the
algorithm of scheduling is stored in the PCB to help in making scheduling
decisions of the OS.
• Accounting Information: The information such as CPU time, memory usage, etc helps the OS to monitor the
performance of the process.
4a) What is inter-process communication? Discuss message passing and the shared memory concept of IPC.
(5m)
A) Inter-process communication (IPC) is a mechanism that allows processes to communicate and synchronize their
actions when running concurrently in an operating system. IPC is essential for sharing data between processes and
ensuring that they can operate in coordination.
UNIT-3
6) Illustrate Peterson’s solution for the critical section problem and explain using algorithm?
A Critical Section problem is a fundamental issue in concurrent programming and operating systems that arises when
multiple processes or threads need to access shared resources. Here's a comprehensive explanation of the Critical
Section problem and the conditions that a solution must satisfy: