Chapter 1 & 2: Introduction
Operating System Concepts – 9th Edit9on Silberschatz, Galvin and Gagne ©2013
Introduction to the Course
Operating systems – essential part of any computer system
Course discusses:
What they are
What they
do
How they are
designed and
structures
Common
features
Processes,Threads, CPU-scheduling, Synchronization, Memory
Management, Virtual Memory, File system interface, advanced topic(s).
Operating System Concepts – 9th Edition 1.2 Silberschatz, Galvin and Gagne ©2013
Main Themes
# Topic
1 Introduction
2 Operating System Structures
3 Processes
4 Threads
5 Process Synchronization
6 CPU Scheduling
7 Deadlock
8 Memory Management
9 Virtual Memory
10 File-System
Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne ©2013
Procedures
Theory: 3 hours per week
Lab: 3 hours per week
Marks Distribution:
• Lab Assessments 25%
• Class Participation : 5%
o Quizzes : 10%
o Mid-Term : 20%
o Final Exam: 40%
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne ©2013
Objectives
To provide a grand tour of the major operating systems
components
To describe the services OS provides to users, processes, and other
systems
To discuss the various ways of structuring an operating system
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne ©2013
General Definition
An OS is a program which acts as an interface between computer system
users and the computer hardware.
It provides a user-friendly environment in which a user may easily develop and
execute programs.
Otherwise, hardware knowledge would be mandatory for computer
programming.
So, it can be said that an OS hides the complexity of hardware
from uninterested users.
Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne ©2013
Example – MS-Paint over
Windows
Assume we are using MS-Paint over Windows - when do we need to access the OS?
Loading the application / terminating the application
Memory allocation / management (e.g., paging)
Access to IO devices – keyboard, mouse, printer, monitor
CPU allocation
Copy / Paste (inter-process communication)
Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne ©2013
OS Support
Since we have an already written library, namely the OS, to
add two numbers we simply write the following line to our
program:
c= a+ b;
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne ©2013
OS Support
In a system where there is no OS installed, we should consider some hardware work
as:
(Assuming an MC 6800 computer hardware) / / Mac Computer
LDAA $80 Loading the number at memory location 80
LDAB $81 Loading the number at memory location 81
ADDB Adding these two numbers
STAA $55 Storing the sum to memory location 55
As seen, we considered memory locations and used our hardware knowledge of the
system.
Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne ©2013
OS Support
In an OS installed machine, since we have an intermediate layer,
our programs obtain some advantage of mobility by not dealing with
hardware.
For example, the program segment would not work
for an 8086 machine, where as the
“c = a + b ;”
syntax will be suitable for both.
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne ©2013
Components of a Computer System
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne ©2013
Components of a Computer System
Computer system can be divided into four components
Hardware – provides basic computing resources
CPU, memory, I/O devices, file storage space
Operating system
Controls and coordinates 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 of the users
Word processors, compilers, web browsers, database systems, video games
Users
People, machines (e.g., embedded), other computers
Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne ©2013
Mode of OS
In a more simplistic approach, in fact, OS itself is a program.
But it has a priority which application programs don’t have.
OS uses the kernel mode of the microprocessor, whereas other programs
use the user mode.
The difference between two is that; all hardware instructions are valid in
kernel mode, where some of them cannot be used in the user mode.
Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne ©2013
Transition from User to Kernel Mode
Dual-mode operation allows OS to protect itself and other system components
User mode and kernel mode
Mode bit provided by hardware
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
Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
• What part here is the OS?
• What are system calls?
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne ©2013
System Calls
Provide interface to the services made available by the OS – the
mechanism by which a program requests a service from an operating
system's kernel
Typically written in a high-level language (C or C++)
On Unix, Unix-like and other POSIX-compatible Operating Systems,
popular system calls are open, read, write, close, wait, exec, fork, exit,
and kill.
Many of today's operating systems have hundreds of system calls.
Linux has 319 different system calls. Similarly, FreeBSD (free Unix-like OS) has
almost 330.
Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne ©2013
Example of System Calls
How many system calls do we need to
copy the contents of one file to another
file?
Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne ©2013
System Calls (cont.) - API
The API specifies the set of functions that are available to the
application programmer, including:
Parameters that are passed to each function
Expected return values
Three most common APIs are
Win32/Win64 API for Windows
POSIX API for POSIX-based systems
(including virtually all versions of UNIX,
Linux, and Mac OS X)
Java API for the Java virtual machine
Operating System Concepts –(JVM)
th 9 Edition 1.18 Silberschatz, Galvin and Gagne ©2013
System Calls (cont.) - API
Why use APIs rather than system calls?
Portability (compiling on different machines)
Simpler calls through API
Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne ©2013
Standard C Library Example
C/C++ program invoking printf()/cout library call, which calls write()
system call
Used in many cases
as
a portion of the system
call interface
User Mode
Kernel Mode
Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne ©2013
Single Task OS
(a) At system startup (b) running a
program
MS-DOS execution
Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne ©2013
Multi-Task/Multi-Program OS
Interpreter is always
running because of the
multiprogramming
FreeBSD Running Multiple Programs
Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne ©2013
OS - Simple Structure
MS-DOS – written to provide the most functionality in the least space
Developed to run a single user, stand alone desktop computer
Manages jobs sequentially
Not divided into modules carefully
Although MS-DOS has some structure, its interfaces and levels of
functionality are not well separated
Windows 1.0-3.1 were merely GUI that ran on top of MS-DOS OS
Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne ©2013
MS-DOS Layer Structure
Malicious programs Application programs
can cause the are able to access the
entire system to basic I/O routines to
crash write directly to
display and disk drives
Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne ©2013
UNIX
UNIX – limited by hardware functionality, the original UNIX operating
system had limited structuring. The UNIX OS consists of two separable parts
Systems programs
The kernel
Consists of everything below the system-call interface and above the
physical hardware
Provides the file system, CPU scheduling, memory management, and
other operating-system functions; a large number of functions for one
level
Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne ©2013
Traditional UNIX System Structure
System
program
s
Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne ©2013
Layered Approach
The operating system is divided into a number of layers (levels), each built
on top of lower layers. The bottom layer (layer 0), is the hardware; the
highest (layer N) is the user interface.
With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers
Simple debugging
Disadvantages:
Efficiency
Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne ©2013
Layered Approach – Unix Advance Structure
Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne ©2013
Students Reading
Operating System Debugging Chapter 2 - Page:86
Operating System Generation Chapter 2 – Page:91
System Boot Chapter 2 – Page:9
• What is multi-user OS?
• Name some multi-user OS’s?
Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne ©2013