Operating Systems - Introduction
Operating Systems - Introduction
Systems
Operating System Concepts – 9th Edition 1.1 Silberschatz, Galvin and Gagne ©2013
Syllabus
Semester: Fall 2023
Instructor : Taner Danisman
Lectures
40 minutes course + 15 minutes break
Location:
Monday :15:30-17:20
Wednesday :13:30-15:20
TextBook:
Operating System Concepts, 9th edition, Silberschatz et al.
Wiley, 2013
Modern Operating Systems, Andrew S. Tanenbaum, 4th Edition,
Pearson, 2015
Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
Prerequisites
Readers familiarity with
Basic data structures
Computer organization
C programming
Reading:
C Coding
https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
Grading
Absolute grading
Assignments : 20% (4 assignments, different weights)
Group assignments is possible
Midterm:30%
Final 50%
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
Topics to be Covered
Week 1 Introduction
Week 2 Operating System Structures
Week 3 Processes
Week 4 Threads
Week 5 Threads
Week 6 Synchronization
Week 7 Synchronization
Week 8 Midterm
Week 9 Classical Problems
Week 10 CPU Scheduling
Week 11 CPU Scheduling
Week 12 Deadlocks
Week 13 Memory Management
Week 14 Virtual Memory
Week 15 Virtual Memory
Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne ©2013
Chapter 1: Introduction
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
What is an Operating System?
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne ©2013
Four Components of a Computer System
Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
What Operating Systems Do – User View
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
Operating System Definition
From the computer’s point of view, the operating system is the program
mostly involved with the hardware.
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
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Operating System Definition (Cont.)
Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne ©2013
Common Functions of Interrupts
Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne ©2013
Interrupt Handling
Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne ©2013
Interrupt Handling (cont.)
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne ©2013
Storage Structure
Main memory – only large storage media that the CPU can access
directly
Random access
Typically volatile
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
Hard disks – rigid metal or glass platters covered with magnetic
recording material
Disk surface is logically divided into tracks, which are subdivided into
sectors
The disk controller determines the logical interaction between the device
and the computer
Solid-state disks – faster than hard disks, nonvolatile
Various technologies
Becoming more popular
Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne ©2013
Storage-Device Hierarchy
Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne ©2013
Direct Memory Access Structure
Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
Two types:
1. Asymmetric Multiprocessing – each processor is assigned a
specific task.
1. A boss processor controls the system; boss-worker relationship
2. Symmetric Multiprocessing (SMP) – each processor performs all
tasks
1. no boss–worker relationship exists
Multiprocessing can cause a system to change its memory access model
from uniform memory access (UMA) to non-uniform memory access
(NUMA)
UMA is defined as the situation in which access to any RAM from any
CPU takes the same amount of time.
With NUMA, some parts of memory may take longer to access than
other parts, creating a performance penalty.
multicore systems are multiprocessor systems
Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne ©2013
Symmetric Multiprocessing Architecture
Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne ©2013
A Dual-Core Design
Multi-chip and multicore
Systems containing all chips
Chassis containing multiple separate systems
Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne ©2013
Operating-System Operations
Interrupt driven (hardware and software)
Hardware interrupt by one of the devices
Software interrupt (exception or trap):
Software error (e.g., division by zero)
– infinite loop
Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne ©2013
Operating-System Operations (cont.)
Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne ©2013
Process Management
A process is a program in execution. It is a unit of work within the
system. Program is a passive entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying
location of next instruction to execute
Process executes instructions sequentially, one at a time,
until completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some
operating system running concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes
/ threads
Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne ©2013
Process Management Activities
Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne ©2013
Migration of data “A” from Disk to Register
Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne ©2013
Performance of Various Levels of Storage
Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne ©2013
Protection and Security
Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne ©2013
Kernel Data Structures
Operating System Concepts – 9th Edition 1.30 Silberschatz, Galvin and Gagne ©2013
Kernel Data Structures
Operating System Concepts – 9th Edition 1.31 Silberschatz, Galvin and Gagne ©2013
Kernel Data Structures
Operating System Concepts – 9th Edition 1.32 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Distributed
Distributed computiing
Collection of separate, possibly heterogeneous, systems
networked together
Network is a communications path, TCP/IP most common
– Local Area Network (LAN)
– Wide Area Network (WAN)
– Metropolitan Area Network (MAN)
– Personal Area Network (PAN)
Network Operating System provides features between
systems across network
Communication scheme allows systems to exchange
messages
Illusion of a single system
Operating System Concepts – 9th Edition 1.33 Silberschatz, Galvin and Gagne ©2013
Computing Environments - Virtualization
Operating System Concepts – 9th Edition 1.34 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Cloud Computing
Operating System Concepts – 9th Edition 1.35 Silberschatz, Galvin and Gagne ©2013
Computing Environments – Real-Time Embedded Systems
Operating System Concepts – 9th Edition 1.36 Silberschatz, Galvin and Gagne ©2013
End of Chapter 1
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
Chapter 2: Operating-System
Structures
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
Schedule
Week 1 Introduction
Week 2 Operating System Structures
Week 3 Processes
Week 4 Threads
Week 5 Threads
Week 6 Midterm 1
Week 7 Synchronization
Week 8 Classical Problems
Week 9 CPU Scheduling
Week 10 CPU Scheduling
Week 11 Midterm 2
Week 12 Deadlocks
Week 13 Memory Management
Week 14 Virtual Memory
Week 15 Virtual Memory
Operating System Concepts – 9th Edition 1.39 Silberschatz, Galvin and Gagne ©2013
Operating System Services
Operating systems provide:
User interface - Almost all operating systems have a user
interface (UI).
Command-Line Interface(CLI), text commands
Graphics User Interface (GUI),
Batch Interface, commands and directives are entered intoa
file and file is executed
Program execution
I/O operations
File-system manipulation Programs need to read and write files
and directories, create and delete them, search them, list file
Information, permission management.
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)
Operating System Concepts – 9th Edition 1.40 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
(Cont.):
Error detection
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 correct and consistent computing
Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
Operating System Concepts – 9th Edition 1.41 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
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,
I/O devices.
Accounting - To keep track of which users use how much and what
kinds of computer resources
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
Operating System Concepts – 9th Edition 1.42 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 1.43 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - CLI
Operating System Concepts – 9th Edition 1.44 Silberschatz, Galvin and Gagne ©2013
Bourne Shell Command Interpreter
Operating System Concepts – 9th Edition 1.45 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - GUI
Operating System Concepts – 9th Edition 1.46 Silberschatz, Galvin and Gagne ©2013
XEROX PARC
Operating System Concepts – 9th Edition 1.47 Silberschatz, Galvin and Gagne ©2013
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) rather than
direct system call use
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 X), and Java API
for the Java virtual machine (JVM)
Operating System Concepts – 9th Edition 1.48 Silberschatz, Galvin and Gagne ©2013
Example of System Calls
System call sequence to copy the contents of one file to another file
Operating System Concepts – 9th Edition 1.49 Silberschatz, Galvin and Gagne ©2013
Example of Standard API
Operating System Concepts – 9th Edition 1.50 Silberschatz, Galvin and Gagne ©2013
API – System Call – OS Relationship
Operating System Concepts – 9th Edition 1.51 Silberschatz, Galvin and Gagne ©2013
System Call Parameter Passing
Operating System Concepts – 9th Edition 1.52 Silberschatz, Galvin and Gagne ©2013
Assembly
Operating System Concepts – 9th Edition 1.54 Silberschatz, Galvin and Gagne ©2013
Examples of Windows and Unix System Calls
Operating System Concepts – 9th Edition 1.55 Silberschatz, Galvin and Gagne ©2013
Standard C Library Example
C program invoking printf() library call, which calls write() system call
Operating System Concepts – 9th Edition 1.56 Silberschatz, Galvin and Gagne ©2013
OS Structure
General-purpose OS is very large program
Various ways to structure ones
Simple structure – MS-DOS
More complex -- UNIX
Layered – an abstraction
Microkernel –Mach
Modules Approach
Operating System Concepts – 9th Edition 1.57 Silberschatz, Galvin and Gagne ©2013
Example: MS-DOS
Single-tasking
Shell invoked when system
booted
Simple method to run
program
No process created
Single memory space
Loads program into memory,
overwriting all but the kernel
Program exit -> shell
reloaded
Operating System Concepts – 9th Edition 1.58 Silberschatz, Galvin and Gagne ©2013
Simple Structure -- MS-DOS
Operating System Concepts – 9th Edition 1.59 Silberschatz, Galvin and Gagne ©2013
Non Simple Structure -- UNIX
Operating System Concepts – 9th Edition 1.60 Silberschatz, Galvin and Gagne ©2013
Layered Approach
Operating System Concepts – 9th Edition 1.61 Silberschatz, Galvin and Gagne ©2013
Microkernel System Structure
Moves as much from the kernel into user space
Mach example of microkernel
Mac OS X kernel (Darwin) partly based on Mach
Communication takes place between user modules using
message passing
Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure
Detriments:
Performance overhead of user space to kernel space
communication
Operating System Concepts – 9th Edition 1.62 Silberschatz, Galvin and Gagne ©2013
Microkernel System Structure
messages messages
microkernel
hardware
Operating System Concepts – 9th Edition 1.63 Silberschatz, Galvin and Gagne ©2013
Modules
Many modern operating systems implement loadable kernel
modules. In computing, a loadable kernel module (LKM) is an
object file that contains code to extend the running kernel, or
so-called base kernel, of an operating system.
Uses object-oriented approach
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel
Overall, similar to layers but with more flexible
Most current Unix-like systems and Microsoft Windows support
loadable kernel modules, although they might use a different
name for them, such as
kernel loadable module (kld) in FreeBSD,
kernel extension (kext) in macOS,
kernel extension module in AIX,
kernel-mode driver in Windows NT and downloadable
kernel module (DKM) in VxWorks.
They are also known as kernel loadable modules (or KLM),
and simply as kernel modules (KMOD).
Disadvantage : fragmentation penalty!
Operating System Concepts – 9th Edition 1.64 Silberschatz, Galvin and Gagne ©2013
Monolithic vs Microkernel
A monolithic kernel is an operating A microkernel (also known as μ-kernel) is the
system architecture where the entire near-minimum amount of software that can
operating system is working in kernel provide the mechanisms needed to implement
space and is alone in supervisor mode an operating system (OS)
Operating System Concepts – 9th Edition 1.65 Silberschatz, Galvin and Gagne ©2013
Linux Kernels
Operating System Concepts – 9th Edition 1.66 Silberschatz, Galvin and Gagne ©2013
Operating-System Debugging
Operating System Concepts – 9th Edition 1.67 Silberschatz, Galvin and Gagne ©2013
Operating-System Debugging
Performance tuning
Monitor system performance
Add code to kernel
Use system tools like “top”
Operating System Concepts – 9th Edition 1.68 Silberschatz, Galvin and Gagne ©2013
End of Chapter 2
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013