Introduction to Operating Systems and Process


 


 Introduction to Operating Systems


1. Operating System

  • Definition: An operating system (OS) is a collection of software that manages  computer hardware and software resources. 
  • Role: The OS acts as an intermediary between users and the computer            hardware, enabling user interaction through applications.

2. Supervisor & User Mode

  1. Supervisor Mode (Kernel Mode):
  • Definition: Kernel mode is a high-privilege state that allows direct access to hardware and system resources
  • Full access to all hardware and system resources.
  • Can execute any instruction and access any memory address.
  • Critical for core OS functions like memory management and process scheduling.
  1. User Mode:
  • Limited access to system resources, preventing direct hardware manipulation.
  • Ensures stability and security by restricting user applications from interfering with the OS.

3. Multiprogramming and Multiprocessing Systems

Multiprogramming:

  • Multiple programs loaded in memory, enabling the CPU to switch between them to maximize CPU utilization.
  • Reduces idle time by keeping the CPU busy with different tasks.
Multiprocessing:
  • Involves multiple CPUs or cores that can execute multiple processes simultaneously.
  • Enhances performance, as processes can run in parallel, improving system responsiveness.

4. OS Structure

Monolithic Structure:

  • All OS services run in kernel mode within a single large block of code.
  • Simple and efficient but less flexible and harder to maintain.
  • Layered Structure:
  • Divides the OS into layers, each with specific responsibilities (e.g., hardware layer, kernel layer, user interface layer).
  • Improves modularity and makes debugging easier.

Microkernel:

  • Minimal core kernel providing basic services (e.g., communication, basic scheduling).
  • Other services (e.g., file systems, drivers) run in user space, improving stability.
  • Modules:
  • Dynamic loading of kernel modules allows the OS to extend its functionality without a reboot.
  • Facilitates easier updates and system enhancements.

5. System Calls

  • Definition: System calls are interfaces through which user applications request services from the OS.
  • Examples:
  • read(): Reads data from a file.
  • write(): Writes data to a file.
  • open(): Opens a file descriptor.
  • close(): Closes a file descriptor.
  • Importance: Allows user-level programs to communicate with the OS and access hardware resources securely.

6. Functions of OS

  • Process Management: Handling process creation, scheduling, and termination.
  • Memory Management: Allocating and managing memory space for processes.
  • File System Management: Managing file operations and directory structures.
  • Device Management: Controlling and coordinating hardware devices.
  • User Interface: Providing command-line or graphical interfaces for user interaction.

7. Evolution of OSs

Early Systems:

  • Batch processing systems that executed jobs sequentially.
  • Simple monolithic kernels without multitasking.
  • Time-sharing Systems:
  • Allowed multiple users to access the system simultaneously.
  • Introduced concepts of multitasking and user interaction.
  • Personal Computer Operating Systems:
  • Emergence of systems like MS-DOS, Windows, and macOS.
  • User-friendly interfaces and support for multitasking.

Modern OS:

  • Advanced OS like Linux, Android, and cloud-based systems.
  • Focus on security, networking, and mobile computing.
  • Process Management

Process Management

1. Process Concept

  • Definition: A process is an active program in execution, consisting of program code, current activity, and the resources allocated to it (like memory, I/O devices).
  • Components:
  • Program Counter: Indicates the next instruction to be executed.
  • Stack: Contains temporary data (e.g., function parameters, return addresses).
  • Data Section: Contains global variables.

2. Life Cycle of a Process

  • New: The process is being created.
  • Ready: The process is in memory and waiting to be assigned to the CPU.
  • Running: The process is currently executing on the CPU.
  • Waiting: The process is waiting for an event to occur (e.g., I/O completion).
  • Terminated: The process has completed execution or has been killed.

3. Process Control Block (PCB)

  • Definition: A PCB is a data structure maintained by the OS that contains information about a process.
  • Components:
  • Process ID (PID): Unique identifier for the process.
  • Process State: Current state of the process (e.g., running, waiting).
  • Program Counter: Address of the next instruction to execute.
  • CPU Registers: Current values of CPU registers.
  • Memory Management Information: Information about memory allocated to the process.
  • I/O Status Information: List of I/O devices allocated to the process.

4. Operations on Processes

  • Creation: Involves allocating resources and initializing the PCB (e.g., using fork() in UNIX).
  • Scheduling: Determining which process to execute based on scheduling algorithms (e.g., Round Robin, Shortest Job First).
  • Termination: Releasing resources when a process finishes or is forcibly terminated.

5. Co-operating and Independent Processes

Independent Processes:

  • Do not affect or get affected by other processes.
  • Operate in isolation.
  • Co-operating Processes:
  • Share data and resources with other processes.
  • Require synchronization to avoid conflicts (e.g., using semaphores or mutexes).

6. Process States

  • Ready: The process is ready to run but waiting for CPU time.
  • Blocked (Waiting): The process cannot continue until an event occurs (e.g., I/O operation completes).
  • Running: The process is actively executing on the CPU.

7. Operations on Processes

  • Fork: Creates a new process (child process) that is a duplicate of the current process.
  • Exec: Replaces the current process's memory space with a new program, effectively running a different program.
  • Wait: A process can wait for another process to finish, preventing it from proceeding until that event occurs.
  • Signal: A process can send a signal to another process to notify it of an event (e.g., completion of I/O).

8. Process Management in UNIX

  • UNIX employs a rich set of process management features, including:
  • Fork and Exec for creating and executing processes.
  • Signals for inter-process communication and synchronization.
  • Process States management via the scheduler.
  • Job Control to manage foreground and background processes.

9. Process Control Block (PCB) in UNIX

  • Similar to the general PCB definition, the UNIX PCB holds essential information for managing processes, ensuring efficient execution and resource allocation.


                 ✋ Thank You For Visiting✋

No comments:

Post a Comment

If you have any doubt, Please let me know.