0% found this document useful (0 votes)
7 views53 pages

Operating Systems 1

The document is a comprehensive syllabus for an Operating Systems course, covering topics such as OS structures, processes, CPU scheduling, and memory management. It explains the role of an operating system as a resource manager and intermediary between users and hardware, detailing its goals, services, and operations. Additionally, it discusses process management, interprocess communication, and multithreading models, emphasizing the importance of efficient resource utilization and system performance.

Uploaded by

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

Operating Systems 1

The document is a comprehensive syllabus for an Operating Systems course, covering topics such as OS structures, processes, CPU scheduling, and memory management. It explains the role of an operating system as a resource manager and intermediary between users and hardware, detailing its goals, services, and operations. Additionally, it discusses process management, interprocess communication, and multithreading models, emphasizing the importance of efficient resource utilization and system performance.

Uploaded by

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

Operating Systems

Course Syllabus

 Introduction to OS.
 Operating System Structures.
 Processes.
 Threads.
 CPU Scheduling.
 Process Synchronization.
 Deadlocks.
 Main Memory Management.
Computer System Structure
 Computer system can be divided into four components:

 Hardware - provides basic computing resources


 CPU, memory, I/O devices

 Operating system
 Controls the use of hardware among various applications and users.

 Application programs
 Define the ways in which the system resources are used to solve the computing
problems for the users.
 Example: Word processors, compilers, web browsers, database systems, video
games.
 Users
 People, machines, other computers.
Cont…
What is an Operating System?

 An operating system is a program that manages a computer's


hardware. It also provides a basis for application programs and
acts as an intermediary between the computer user and the
computer hardware.
Operating System Goals

 Execute user programs and make solving user problems easier.

 Make the computer system suitable to use.

 Use the computer hardware in an efficient manner.


What Operating Systems Do?

 User View

 Users want enjoyment, ease of use and good performance.


 Don't care about resource utilization.

 But shared computer such as mainframe or minicomputer must


keep all users happy.
Cont…

 System View

 A computer system has many resources that may be required


to solve a problem: CPU time, memory space, file-storage
space, I/O devices, and so on.
 So, the operating system acts as the manager of these
resources.

 It is also called by the Resources Allocator.


Cont…

 OS is a resource allocator
• Manages all resources.
• Decides between conflicting requests for efficient and fair resource use.

 OS is a control program
• Controls execution of programs to prevent errors and improper use of the computer.
Cont…
 A more common definition, and the one that we usually follow, is that
 The operating system is the one program running at
all times on the computer memory usually called the kernel.

 Kernel Definition: The kernel is the central part of an operating system


responsible for managing hardware resources, providing services to applications,
and controlling the flow of data between devices.

 Along with the kernel, there are two other types of programs:
• System Programs, which are associated with the operating system but are not
necessarily part of the kernel.

• Application Programs, which include all programs not associated with the
operation of the system.
Computer Startup

 In Operating Systems (OS), Bootstrap refers to the process of loading the


operating system into memory.
 Bootstrap Process:

1. Power-on Self-Test (POST): The computer's BIOS (i.e., Basic Input/ Output system) or
UEFI (i.e., Unified Extensible Firmware Interface) firmware performs hardware checks.
2. Bootloader: The BIOS/UEFI loads the bootstrap from the boot device (e.g., hard drive,
SSD).
3. Bootstrap Execution: The bootstrap loads the operating system kernel into the memory.
4. Kernel Initialization: The kernel initializes device drivers, memory management, and
system services.
5. Operating System Load: The kernel loads the operating system's core components.
Cont…
How a modern computer works..
Multiprocessing Architecture

 Multiprocessors systems growing in use and importance.


 Also known as parallel systems.

 Advantages include:
• Increased throughput: by increasing the number of processors, we expect to get
more work done in less time.
• Economy of scale: Multiprocessor systems can cost less than equivalent multiple
single-processor systems, because they can have the same hardware resources.

 Two types of Multiprocessors:


• Asymmetric Multiprocessing each processor is assigned a specie task.
• Symmetric Multiprocessing each processor performs all tasks.
Multiprocessor Systems Vs. Multicore Processor Systems

 Multiprocessor System:
1. Multiple processors (CPUs) connected together.
2. Each processor has its own memory and I/O systems.
3. Processors communicate through interconnects (bus, network).
Example: Distributed Systems.

 Multicore Processor System:


1. Single processor (CPU) with multiple processing cores.
2. Cores share memory and I/O systems.
3. Cores communicate through shared cache, bus.
4. Increased processing power, reduced power consumption.
Example: Smartphones, Laptops…etc.
Cont…
Operating System Operations

 Dual-mode operation allows OS to protect itself and other system


components.
• User mode and kernel mode (also called supervisor mode, system mode, or privileged
mode).

 A bit, called the mode bit, is added to the hardware of the computer to indicate
the current mode: kernel (0) or user (1).
• Provides ability to distinguish when system is running user code or kernel code.
• Some instructions designated as privileged, only executable in kernel mode.
• System call changes mode to kernel, return from call resets it to user.
Virtualization

 Virtualization is a technology that allows operating systems


to run as applications within other operating systems.

 Consider VMware/ VirtualBox running WinXP guests, each running


applications, all on native Windows10 host OS.
 VMM (virtual machine Manager) provides virtualization services.
VMware Architecture
Operating System Services

 Operating systems provide an environment for execution of programs and


services to programs and users.
Cont…

 Part-I: The services that are helpful to the user.

 User interface (UI): Almost all operating systems have a user interface
• Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch.

 Program Execution: The system must be able to load a program into memory
and to run that program and end execution

 I/O Operations: A running program may require I/O, which may involve a file
or an I/O device.

 File-System Manipulation: The file system is of particular interest. Programs


need to read and write files and directories, create and delete them, search
them, list file Information.
Cont…

 Communications: Processes may exchange information, on the same


computer or between computers over a network. Communications may be via
shared memory or through message passing (packets moved by the OS).

 Error Detection: OS needs to be aware about the possible errors.


• May occur in the CPU and memory hardware, in I/O devices, in user program.
• For each type of error, OS should take the appropriate action to ensure the correct
computing.
Cont…
 Part-II: The services that are ensuring the efficient operation of the system
itself via resource sharing.

 Resource Allocation: When multiple users or multiple jobs running


concurrently, resources must be allocated to each of them.
• Many types of resources- CPU cycles, main memory, file storage, and I/O devices.

 Accounting: To keep track the users, how much and what kinds of computer
resources they are used.

 Protection and security: The owners of information stored in a multiuser or


networked computer system may want to control use of that information,
concurrent processes should not interfere with each other.
• Protection involves ensuring that all access to system resources is controlled.
• Security of the system from outsiders requires user authentication, extends to defending
external I/O devices from invalid access attempts.
System Calls

 Programming interface to the services provided by the OS.

 Typically written in a high-level language (C or C++).

 Mostly accessed by programs via a high-level Application Programming


Interface (API).

 Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux, and
Mac OS).
Cont…

 Example: System call sequence to copy the contents of one file to another file.
Cont…
Cont…

 C program invoking printf() library call, which calls write() system call.
Processes Concept

 Program vs. Process

 A program is a passive entity such as the file that contains the list of
instructions stored on a disk always referred to as an executable file.

 A program becomes a process when an executable file is loaded into the


memory and then becomes an active entity.

 The fundamental task of any operating system is the process management.

 Processes include not only a text but also include a set of resources such as
open files and pending signals. Processes also contain internal kernel data,
process state, an address space, and a data section.
Cont…

 OS must allocate resources to processes, enable sharing of information,


protect resources, and enable the synchronization among processes.
Process Elements

 Segments of a process represents the following components:

 Text Section: the program code. This is typically read-only, and might be
shared by a number of processes.
 Data Section: containing global variables.
 Heap: containing memory dynamically allocated during run time.
 Stack: containing temporary data.
• Function parameters, return addresses, local variables.
Cont…

 Process in Memory.
Process Control Block (PCB)

 For better control of processes, operating systems need to consider their


dynamic behaviors.
 Each process is represented in the OS by a Process Control Block (PCB).
Cont…

 Process identification information


• Process identifier: numeric identifiers represent the unique process identifier
• User identifier: the user who is responsible for the job.
• Identifier of the parent process that created this process.

 Process State Information


• Process state- running, waiting, etc..

 Program Counter
• Location of instruction to next execute.

 CPU Registers
• Contents of all process-centric registers.
Cont…

 CPU Scheduling Information


• Priorities, scheduling queue pointers.

 Memory-Management Information
• Memory allocated to the process.

 Accounting Information
• CPU used, clock time elapsed since start, time limits.

 I/O Status Information


• I/O devices allocated to process, list of open files.
Process State

 As a process executes, it changes state

 New: The process is being created.


 Ready: The process is waiting to be assigned to a processor.
 Running: Instructions are being executed.
 Waiting: The process is waiting for some event to occur.
 Terminated: The process has finished execution.
Cont…
Cont…
Cont…
Process Scheduling

 Job queue- set of all processes in the system.


 Ready queue- set of all processes residing in main memory, ready and waiting
to execute.
 Device queues- set of processes waiting for an I/O device.
 Processes migrate among the various queues.
Cont…
Scheduler

 Short-term scheduler (or CPU scheduler)


• Selects which process should be executed next and allocates CPU.
• Invoked frequently (milliseconds) → (must be fast).

 Long-term scheduler (or job scheduler)


• Selects which processes should be brought into the ready queue.
• Invoked infrequently (seconds, minutes) → (may be slow).
• Controls the degree of multiprogramming.
Cont…

 Medium-term Scheduler
• Can be added if degree of multiple programming needs to decrease.
• Remove process from memory, store on disk, bring back in from disk to continue
execution: swapping.
Interprocess Communication

 Processes within a system may be independent or cooperating.


 Cooperating process can affect or be affected by other processes, including
sharing data.
 Cooperating processes need interprocess communication (IPC)
 Two models of IPC:
• Shared Memory.
• Message Passing.
Threads

 A thread is a basic unit of CPU utilization; it comprises a thread ID, a program


counter, a register set, and a stack.

 It shares with other threads belonging to the same process its code section,
data section, and other operating-system resources, such as open files and
signals.
Cont…

 Let's say, for example, a program is not capable of drawing pictures while
reading keystrokes. The program must give its full attention to the keyboard
input lacking the ability to handle more than one event at a time.

 The ideal solution to this problem is the seamless execution of two or more
sections of a program at the same time. Threads allows us to do this.
Cont…

 Most software applications that run on modern computers are multithreaded.

 An application typically is implemented as a separate process with several


threads of control.

• A web browser might have one thread display images or text while another thread
retrieves data from the network, for example.

• A word processor may have a thread for displaying graphics, another thread for
responding to keystrokes from the user, and a third thread for performing spelling and
grammar checking in the background.
Cont…

 Multithreaded Server Architecture

 Finally, most operating-system kernels are now multithreaded. Several threads


operate in the kernel, and each thread performs a specific task, such as
managing devices, managing memory, or interrupt handling.
Multicore Programming

 Multithreaded programming provides a mechanism for more efficient use of


these multicore or multiprocessor systems.
Multithreading Models

 Support for threads may be provided either at the user level, for user threads,
or by the kernel, for kernel threads.
 User threads are supported above the kernel and are managed without kernel
support, whereas kernel threads are supported and managed directly by the
operating system.

 Ultimately, a relationship must exist between user threads and kernel threads.
 We look at three common models:
• The one-to-one model,
• The many-to-one model, and
• The many-to-many model.
One-to-One Model

 The one-to-one model maps each user thread to a kernel thread. It also allows
multiple threads to run in parallel on multiprocessors.

 The only drawback to this model is that creating a user thread requires creating
the corresponding kernel thread.
 Because the overhead of creating kernel threads can burden the performance of
an application, most implementations of this model restrict the number of
threads supported by the system.
Many-to-One Model
Many-to-Many Model

 Allows many user level threads to be mapped to many kernel threads.


 Allows the operating system to create a sufficient number of kernel threads.
 Allows the developer to create as many user threads as he/ she wishes, it does
not result in true concurrency, because the kernel can schedule only one thread
at a time
Benefits of Threads

 Responsiveness- may allow continued execution if part of process is blocked,


especially important for user interfaces.

 Resource Sharing- threads share resources of process, easier than shared


memory or message passing.

 Economy- cheaper than process creation, thread switching lower overhead than
context switching.

 Scalability- process can take advantage of multiprocessor architectures.

You might also like