0% found this document useful (0 votes)
25 views8 pages

Os Mid

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

Os Mid

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

UNIT -1

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.

Types of System Calls


There are five main categories of system calls:

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.

6. Security and Privacy


• User Authentication: Verifies user identities.
• Access Control: Restricts access to system resources based on user permissions.
• Cryptography: Encrypts and decrypts data to protect it from unauthorized access.
• Malware Protection: Detects and prevents malware attacks.
7. Resource Management
• CPU Scheduling: Determines the order in which processes are executed.
• Memory Management: Allocates and deallocates memory.
• I/O Device Management: Controls the access and operation of I/O devices.
• Process Management: Manages the creation, execution, and termination of processes.
8. User Interface
• Graphical User Interface (GUI): Provides a visual interface with icons, windows, and menus.
• Command-Line Interface (CLI): Offers a text-based interface for users who prefer to interact with the
system using commands.
9. Error Handling
• Error Detection: Detects errors that occur during system operation.
• Error Recovery: Takes appropriate actions to recover from errors.
10. Time Management
• Clock Maintenance: Keeps track of system time.
• Time-Related Services: Provides services related to time, such as scheduling tasks and setting alarms.

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:

Critical Section Problem


The Critical Section problem refers to the challenge of ensuring that when one process is executing in its critical
section (a segment of code that accesses shared resources), no other process is allowed to execute in its critical section
simultaneously. This is crucial to prevent race conditions and maintain data consistency in multi-process or multi-
threaded environments
First-Come, First-Served (FCFS)
FCFS is a simple scheduling algorithm where the process that arrives first gets executed first. It's non-
preemptive, meaning once a process starts execution, it runs to completion.
Round Robin (RR)
Round Robin is a preemptive scheduling algorithm where each process gets executed for a fixed time slice
or quantum. If a process doesn't finish in its time slice, it's moved to the back of the queue.
Shortest Remaining Time First (SRTF)
SRTF is a preemptive scheduling algorithm that selects the process with the shortest remaining burst time to
execute next. It allows a new process with a shorter burst time to preempt the currently running process.
Priority Scheduling
Priority Scheduling selects processes based on priority levels. The process with the highest priority (often
the lowest numerical value) is selected for execution first. It can be either preemptive or non-preemptive.
Gantt chart
A Gantt chart is a visual representation of a schedule that displays the start and finish times of various tasks,
processes, or activities. In the context of CPU scheduling, it shows the order in which processes are executed
over time.

Turnaround Time (TAT):


• The total time taken from the arrival of a process to its completion.
• Formula: TAT=Completion Time−Arrival TimeTAT=Completion Time−Arrival Time
Waiting Time (WT):
• The total time a process spends waiting in the ready queue before it gets executed.
• Formula: WT=Turnaround Time−Burst TimeWT=Turnaround Time−Burst Time

You might also like