0% found this document useful (0 votes)
2 views15 pages

Chapter 1. Operating System Basics: Q. Define Operating System. Explain Its Main Functions

An Operating System (OS) is system software that serves as an interface between users and computer hardware, managing resources and providing essential services. Its main functions include process management, memory management, file system management, device management, security, user interface, networking, and performance monitoring. System calls act as a controlled gateway for user applications to request services from the OS, and processes transition through various states managed by the OS, utilizing structures like the Process Control Block (PCB) for effective process management.

Uploaded by

darshanawale02
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)
2 views15 pages

Chapter 1. Operating System Basics: Q. Define Operating System. Explain Its Main Functions

An Operating System (OS) is system software that serves as an interface between users and computer hardware, managing resources and providing essential services. Its main functions include process management, memory management, file system management, device management, security, user interface, networking, and performance monitoring. System calls act as a controlled gateway for user applications to request services from the OS, and processes transition through various states managed by the OS, utilizing structures like the Process Control Block (PCB) for effective process management.

Uploaded by

darshanawale02
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/ 15

Chapter 1.

Operating System Basics

Q. Define Operating System. Explain its main functions.


Definition of Operating System:

An Operating System (OS) is a system software that acts as an interface between the user and the
computer hardware. It manages the computer's hardware resources and provides essential services
for computer programs. In simple terms, it controls and coordinates the use of hardware among
various application programs and users.

Main Functions of Operating System:

The primary functions of an operating system are as follows:

1. Process Management

• Manages the execution of multiple processes (programs in execution).

• Handles process scheduling, creation, termination, and synchronization.

• Ensures efficient CPU utilization through techniques like multitasking, multiprocessing, and
multithreading.

2. Memory Management

• Allocates and deallocates memory to processes.

• Manages RAM and virtual memory to optimize performance.

• Prevents memory conflicts between different applications.

3. File System Management

• Organizes and manages files and directories on storage devices.

• Handles file creation, deletion, reading, and writing.

• Ensures data integrity and security through permissions.

4. Device Management (I/O Management)

• Controls and coordinates input/output (I/O) devices like keyboards, printers, and disks.

• Uses device drivers to communicate with hardware.

• Manages buffering, caching, and spooling for efficient I/O operations.

5. Security and Access Control

• Protects data and resources through authentication (user login) and authorization
(permissions).
• Prevents unauthorized access using firewalls, encryption, and user roles.

6. User Interface (UI)

• Provides an interface for users to interact with the system.

o Graphical User Interface (GUI) (e.g., Windows, macOS).

o Command-Line Interface (CLI) (e.g., Linux Terminal, Command Prompt).

7. Networking & Communication

• Manages network connections and data transfer between computers.

• Handles protocols like TCP/IP, HTTP, FTP for internet and local network communication.

8. Resource Allocation & Performance Monitoring

• Distributes CPU time, memory, and I/O devices among competing processes.

• Monitors system performance and optimizes resource usage.

In summary, an operating system is essential for managing system resources, ensuring smooth
operation, and providing a user-friendly environment for users and applications.
Q. What are system calls? Describe their types with examples

What are System Calls?

System calls are the programming interface between the operating system and user-level
programs. They allow user applications to request services from the kernel of the operating system,
such as file operations, process control, device handling, etc.

Since user programs cannot directly access hardware or kernel data structures for protection and
stability reasons, system calls act as a controlled gateway to access these services.

Types of System Calls with Examples:

System calls are broadly categorized into five main types, based on the services they provide:

1. Process Control:

Used for creating, terminating, and managing processes.

Examples:

• fork() – creates a new process.

• exit() – terminates the current process.


• exec() – replaces the current process image with a new one.

• wait() – waits for a process to finish execution.

2. File Management:

Used for file operations like creation, deletion, reading, and writing of files.

Examples:

• open() – opens a file.

• read() – reads data from a file.

• write() – writes data to a file.

• close() – closes a file.

• unlink() – deletes a file.

3. Device Management:

Used to request and release devices, and perform I/O operations.

Examples:

• read() – reads from a device.

• write() – writes to a device.

• open() / close() – opens or closes device files.

4. Information Maintenance:

Used to get or set system data, time, or process information.

Examples:

• getpid() – gets the current process ID.

• alarm() – sets an alarm timer.

• sleep() – suspends execution for a specified time.

• time() – returns the current system time.

5. Communication:

Used to establish communication between processes either on the same system or over a network.

Examples:

• pipe() – creates a pipe for inter-process communication (IPC).


• shmget() – allocates a shared memory segment.

• send() / recv() – sends and receives messages via sockets.

• socket() – creates a communication endpoint.

Summary:

System calls are essential for performing tasks that require direct interaction with the operating
system. They provide a safe and controlled way for user programs to utilize the services offered by
the OS kernel
2. Process Management & Scheduling

Q. Explain process states with a state transition diagram


Process States in Operating System:

A process goes through different states during its lifetime. The operating system manages the
transitions between these states to ensure proper execution and resource utilization.

Basic Process States:

1. New:
The process is being created.

2. Ready:
The process is waiting to be assigned to a processor (CPU).

3. Running:
The process is currently being executed by the CPU.

4. Waiting (Blocked):
The process is waiting for some event to occur (like I/O completion).

5. Terminated (Exit):
The process has completed execution or has been terminated.

State Transition Diagram:


Explanation of Transitions:
• New → Ready:
When a process is created, it is moved to the Ready state after initialization.

• Ready → Running:
The scheduler selects a process from the ready queue and assigns the CPU to it.

• Running → Waiting:
If the process requests an I/O operation or waits for some event, it is moved to the Waiting
state.

• Running → Ready:
If the running process is preempted (e.g., time slice ends in a time-sharing system), it returns
to the Ready state.

• Waiting → Ready:
Once the I/O or event is completed, the process goes back to the Ready queue.

• Running → Terminated:
When the process finishes execution or is killed, it moves to the Terminated state.

Conclusion:

These process states and transitions are essential for multitasking and resource sharing. The
operating system constantly monitors and controls these states to ensure smooth and efficient
process management
Q: Explain Process Control Block (PCB) and its contents.

Process Control Block (PCB):

The Process Control Block (PCB) is a data structure maintained by the Operating System for every
process. It contains all the information about a specific process that is required for process
management.

Whenever a context switch occurs (i.e., when the CPU switches from one process to another), the
OS saves the state of the current process in its PCB and loads the state of the next process from its
PCB.

Contents of PCB:

The main components of a PCB include:


Contents of the PCB (as per the image):

1. Process ID:
A unique identifier assigned to every process.

2. Process State:
Indicates the current state of the process (New, Ready, Running, Waiting, or Terminated).

3. Process Priority:
Determines the priority level of the process for scheduling purposes.

4. Accounting Information:
Keeps track of resource usage statistics like CPU time, memory usage, time limits, etc.

5. Program Counters:
Stores the address of the next instruction to be executed.

6. CPU Registers:
Includes all general-purpose registers, stack pointers, etc., required for process execution.

7. PCB Pointers:
Pointers to other PCBs, used in managing process queues and hierarchies (e.g., child or
parent processes).

8. List of Open Files:


Tracks all files that are currently opened by the process.

9. Process I/O Status Information:


Contains details about I/O devices allocated to the process and any pending I/O requests.

10. (Additional entry “.............”)


Indicates that other system-specific or optional information may be included, such as:

Conclusion:

The PCB plays a vital role in context switching and process management. It allows the operating
system to resume a process exactly where it left off by storing all essential details. Each running
process has its own PCB, and the OS uses these blocks to manage multitasking effectively.
Q. Compare FCFS, SJF (preemptive/non-preemptive), Priority, and Round Robin
scheduling.
Q.: What is context switching? Describe kernel actions.

What is Context Switching?

Context switching is the process by which the operating system saves the state of a currently
running process and loads the state of another process so that execution can continue from the
point it was paused.

It occurs during multitasking when the CPU switches from one process or thread to another,
enabling multiple processes to share a single CPU efficiently.

Diagram (Text-based):

Why Context Switching is Needed:

• To support multitasking/multiprocessing

• When a higher priority process becomes ready

• On interrupts or I/O requests

• When time quantum expires (in time-sharing systems)

Contents Saved/Restored During Context Switch:

• Program Counter (PC)


• CPU Registers

• Process State

• Memory Management Info

• Stack Pointer

• Other CPU-specific data

Kernel Actions During Context Switching:

The kernel performs several steps during a context switch:

1. Save the Context of the Current Process:

• The CPU state (registers, PC, stack pointer, etc.) of the currently running process is saved
into its Process Control Block (PCB).

2. Update PCB Status:

• The process state is changed from Running to Ready or Waiting depending on the reason
for the switch.

3. Select a New Process to Run:

• The CPU scheduler selects the next process to run based on the scheduling algorithm (e.g.,
FCFS, SJF, Round Robin).

4. Load the Context of the New Process:

• The CPU registers, PC, and other information are loaded from the new process’s PCB.

5. Transfer Control to the New Process:

• The kernel returns control to the user space of the new process, and it begins/resumes
execution.

Conclusion:

Context switching is essential for efficient CPU utilization and system responsiveness. However, it
introduces overhead, since saving and loading states takes time without performing useful
computation during the switch. Efficient OS design aims to minimize context switching while
maintaining fairness and responsiveness.
Q. Difference between process and thread (give in columns)

Aspect Process Thread

An independent program in A lightweight unit of execution within a


Definition
execution process

Has its own separate memory Shares memory space with other threads
Address Space
space in the same process

Requires Inter-Process Easy communication through shared


Communication
Communication (IPC) memory

Higher (due to separate memory, Lower (uses existing process memory


Overhead
resources) and resources)

Creation Time Slower (heavyweight) Faster (lightweight)

Termination Time Slower Faster

Slower (more data to save and


Context Switching Faster (less data involved)
load)

One process crashing does not One thread crashing can affect the entire
Crash Impact
affect others process

Has its own resources (e.g., file


Resource Allocation Shares resources of the parent process
descriptors, memory)

Multi-threaded applications like


Used In Multi-process applications
browsers, servers
Q. Explain the role of long term, short term and middle term scheduler in
process scheduling.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy