















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
INTRODUCTION TO OPERATING SYSTEMS FOR BEGINNERS. CONTAINS UNDERSTANDABLE ENGLISH, AND PICTORIAL REPRESENTATIONS (IMAGES)FOR NETTER UNDERSTANDING.
Typology: Lecture notes
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















An Operating System (OS) is an interface between user and computer system. It is system software that manages a computer's hardware and software resources and provides common services for computer programs. Functions of an Operating System:
Computer-System Organization refers to the structural design and interaction of the various components that make up a computer system. It describes how hardware components like the CPU, memory, input/output (I/O) devices, and storage work together under the control of the operating system.
Key Components of Computer-System Organization:
Arithmetic Logic Unit (ALU) : Performs arithmetic and logic operations. Control Unit (CU) : Directs operations within the computer. Registers : Small, fast memory used to store intermediate data and instructions.
Operating system (OS) provides a set of essential services that enable both users and programs to interact with the hardware and other software components efficiently and safely. These services fall into various categories based on the functionality they provide.
1. User Interface Services These services provide ways for users to interact with the system: Command-Line Interface (CLI): Allows users to type commands (e.g., Unix shell). Graphical User Interface (GUI): Offers visual interaction with icons, windows, and menus (e.g., Windows, macOS). 2. Program Execution The OS provides services to load programs into memory and execute them. It manages: Memory allocation Process scheduling Program termination 3. I/O Operations For programs that need to perform input and output, the OS provides: Interfaces to hardware devices (keyboard, mouse, printers) Abstracts hardware differences for ease of programming
System calls are classified into the following categories: File System : Used to create, open, read, write, and manage files and directories. Process Control : Used to create, execute, synchronize, and terminate processes. Memory Management : Used to allocate, deallocate, and manage memory for processes. Interprocess Communication (IPC) : Used for data exchange and communication between different processes. Device Management : Used to request and release devices, and to perform read/write operations on them.
__
A process in is a program in execution, an active instance of a software program that the operating system manages, distinguishing it from a program file. It includes the program code, its current activity (program counter, registers), data, and resources like memory, with its state tracked in a Process Control Block (PCB) , allowing multitasking through scheduling and context switching
Process states describe a process's current activity, typically moving through New, Ready, Running, Waiting/Blocked, and Terminated, plus suspended states as it's created, executes, waits for resources (like I/O), or finishes, managed by the OS for efficient multitasking. Here are the states: New (or Created): The process is being created, but not yet ready for execution. Ready: The process is loaded into main memory, prepared to run, and waiting for the CPU to be assigned. Running: The CPU is currently executing the process's instructions. Waiting (or Blocked): The process is paused, waiting for an event, like an I/O operation to complete or a signal to arrive. Terminated (or Completed): The process has finished execution and is being removed from the system.
__
The operating system provides several operations to manage processes during their lifecycle.
1. Process Creation A process can create a new process using a system call (e.g., fork() in Unix). The parent process creates child processes , forming a process tree.
In an Operating System (OS), a thread is the smallest unit of execution within a process, allowing a single program to perform multiple tasks concurrently (like running different browser tabs or handling text input and background saving in a word processor). Threads are called "lightweight processes" because they share the process's resources (memory, files) but have their own program counter, registers, and stack, making them faster to create and switch between than separate processes.
In an OS, Multicore Programming involves designing software to run on processors with multiple execution "cores" (mini-processors on one chip) to achieve true parallelism, executing different tasks or parts of a single task simultaneously for significant performance gains, improved efficiency, and scalability, overcoming single- core speed limits. It requires the OS to schedule threads across cores and programmers to write multithreaded code that can be broken down into independent, concurrent operations, managing shared memory. How it Works in an OS Hardware : A single CPU chip contains two or more independent processing units (cores) that can fetch and execute instructions simultaneously. OS Role : The operating system's scheduler assigns different threads (lightweight processes) to different cores, keeping them busy and maximizing CPU utilization, which is crucial for performance.
Concurrency & Parallelism: It enables true parallelism , where multiple instructions run at the exact same instant, unlike single-core multitasking (concurrency) which rapidly switches between tasks. _____________________________________________________________
Multithreading models in an Operating System (OS) define the relationship between user-level threads (managed by the application) and kernel-level threads (managed by the OS) and include three main types: Many-to-One (many user threads to one kernel thread), One-to-One (each user thread maps to a unique kernel thread), and Many-to-Many (multiplexes many user threads to a smaller or equal number of kernel threads). These models dictate concurrency, performance, and resource utilization, with Many-to-Many generally offering the best balance by allowing parallelism.
1. Many-to-One Model Description: Multiple user threads are mapped to a single kernel thread. Pros: Thread management is efficient as it's done in user space. Cons: A blocking system call by one thread blocks all others; cannot utilize multiple CPU cores for true parallelism. 2. One-to-One Model Description: Each user thread is directly mapped to a separate kernel thread. Pros: Allows true parallelism on multi-core processors; if one thread blocks, others can still run. Cons: High overhead due to creating many kernel threads; can limit the number of threads. Examples: Windows XP, Linux (threads are tasks). 3. Many-to-Many Model Description: Multiplexes many user threads to a smaller or equal number of kernel threads. Pros: Combines benefits, avoiding the limitations of the other two; good concurrency and efficient blocking. Cons: More complex to implement. Examples: Solaris, modern Linux (threads are tasks).
Thread Pools: Managing a fixed number of threads to avoid resource exhaustion from creating too many threads for concurrent requests, as seen in web servers.
CPU Scheduling is the mechanism the operating system uses to decide which of the many ready processes gets to use the CPU next, maximizing CPU utilization, throughput, and fairness while minimizing waiting and response times, essential for multitasking by efficiently allocating the single (or limited) CPU among competing processes. It involves algorithms (like FCFS, SJF, Round Robin) and managing queues (ready, waiting) to switch between processes when one waits for I/O or completes, creating the illusion of simultaneous execution. Key Concepts: Purpose: To keep the CPU busy, efficiently manage resources, and provide good user experience in multitasking systems. Scheduler: The short-term scheduler (CPU Scheduler) makes the decision of which process to run next from the ready queue. Queues: Processes move between Ready Queue (processes waiting for CPU), Running State, and Waiting Queue. (for I/O). Context Switching: The process of saving the state of one process and loading the state of another, facilitated by the scheduler. Types of Scheduling: Non-Preemptive: A process runs until it finishes or blocks (e.g., for I/O). Preemptive: The OS can interrupt a running process to allocate the CPU to a higher-priority process or for time-slicing (e.g., Round Robin). Common Algorithms: First-Come, First-Served (FCFS): Processes run in the order they arrive. Shortest Job First (SJF): Runs the process with the smallest execution time next. Round Robin (RR): Gives each process a small time slice (quantum) in turns. Priority Scheduling: Assigns priorities, running higher-priority processes first.
Goals (Criteria): Maximize CPU Utilization & Throughput (jobs completed per unit time). Minimize Turnaround Time (total time in system), Waiting Time, and Response Time (time to first response).
CPU scheduling criteria in an OS are metrics used to decide process execution order, focusing on maximizing CPU utilization, throughput (processes/time), and minimizing turnaround time (submission to completion), waiting time (in ready queue), and response time (request to first output) for efficient, fair, and responsive system performance. Key CPU Scheduling Criteria:
o This is a pre-emptive scheduling algorithm. o Best approach to minimize waiting time. o Easy to implement in Batch systems where required CPU time is known in advance. o The processer should know in advance how much time process will take.
Process Id Arrival time Burst time P1 3 1 P2 1 4 P3 4 2 P4 0 6 P5 2 3
Process Id Exit time Turn Around time Waiting time P1 4 4 – 3 = 1 1 – 1 = 0
These algorithms allow the OS to pause a running process to allocate the CPU to a higher-priority task or for time-sharing. Round Robin (RR): Each process is allocated a fixed time slice called a quantum. Once the time is up, the process is moved to the back of the queue.