Silberschatz, Galvin and Gagne ©2005. Operating System Concepts – 7th
Edition, Jan 12, 2005. ▫ Term: Spring 2009. ▫ Instructor: Dr. Lo'ai Tawalbeh. ▫
Email:.
Lecture1: Introduction
Term:
Spring 2009
Instructor:
Dr. Lo’ai Tawalbeh
Email:
[email protected]
Class:
Wed 6:00 pm- 9:00 pm – Amman’s Campus
Prerequisites: z
CSCI 370 -- Introduction to Computer Networks
z
ITEC 385 -- Introduction to Computer and Network Security or Equivalents.
See syllabus for other important info: z
Exams
z
Attendance
z
Text and References
Operating System Concepts – 7th Edition, Jan 12, 2005
1.2
Silberschatz, Galvin and Gagne ©2005
What is an Operating System? A program that acts as an intermediary between a user of a
computer and the computer hardware. Operating system goals: z
Execute user programs and make solving user problems easier (Provide an environment in which a user can execute programs in a convenient and efficient manner).
z
Manage the computer hardware in such a way as to ensure correct operation of the computer system and prevent user programs from interfering with the proper operation of the system.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.3
Silberschatz, Galvin and Gagne ©2005
Computer System Structure Computer system can be divided into four components z
Hardware – provides basic computing resources CPU,
z
memory, I/O devices
Operating system Controls
and coordinates use of hardware among various applications and users
z
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
z
Users People,
machines, other computers
Operating System Concepts – 7th Edition, Jan 12, 2005
1.4
Silberschatz, Galvin and Gagne ©2005
Four Components of a Computer System
Operating System Concepts – 7th Edition, Jan 12, 2005
1.5
Silberschatz, Galvin and Gagne ©2005
Operating System Definition
OS is a resource allocator z Manages all resources z
Decides between conflicting requests for efficient and fair resource use
OS is a control program z Controls execution of programs to prevent errors and improper use of the computer
No universally accepted definition. z
“Everything a vendor ships when you order the operating system” is one definition.
“The one program running at all times on the computer” is the one generally used in this course. This is the kernel. z Everything else is either a system program (ships with the operating system) or an application program. z
Operating System Concepts – 7th Edition, Jan 12, 2005
1.6
Silberschatz, Galvin and Gagne ©2005
Multiprogrammed Systems Multiprogramming needed for efficiency z
Single user cannot keep CPU and I/O devices busy at all times
z
Multiprogramming organizes jobs (code and data) so CPU always has one to execute (increase CPU utilization).
z
Idea: a subset of total jobs in system is kept in memory
z
One job selected and run via job scheduling
z
When it has to wait (for I/O for example), OS switches to another job
OS Features Needed for Multiprogramming z
I/O routine supplied by the system.
z
Memory management – the system must allocate the memory to several jobs.
z
CPU scheduling – the system must choose among several jobs ready to run.
z
Allocation of devices.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.7
Silberschatz, Galvin and Gagne ©2005
Memory Layout for Multiprogrammed System
Operating System Concepts – 7th Edition, Jan 12, 2005
1.8
Silberschatz, Galvin and Gagne ©2005
Timesharing System (Interactive Systems)
Timesharing (multitasking) CPU switches between jobs so frequently that users can interact with each job while it is running, creating interactive computing
The jobs are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory).
A job swapped in and out of memory to the disk.
On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard.
features: z
Response time should be < 1 second
z
Each user has at least one program executing in memory >process
z
If several jobs ready to run at the same time > CPU scheduling
z
If processes don’t fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
Operating System Concepts – 7th Edition, Jan 12, 2005
1.9
Silberschatz, Galvin and Gagne ©2005
Parallel Systems Multiprocessor systems with more than on CPU in close
communication. Tightly coupled system – processors share memory and a clock;
communication usually takes place through the shared memory. Advantages of parallel system: z
Increased throughput
z
Economical
z
Increased reliability graceful
degradation
Operating System Concepts – 7th Edition, Jan 12, 2005
1.10
Silberschatz, Galvin and Gagne ©2005
Parallel Systems (Cont.) Symmetric multiprocessing (SMP) z
Each processor runs and identical copy of the operating system.
z
Many processes can run at once without performance deterioration.
z
Most modern operating systems support SMP
Asymmetric multiprocessing z
Each processor is assigned a specific task; master processor schedules and allocated work to slave processors.
z
More common in extremely large systems
Operating System Concepts – 7th Edition, Jan 12, 2005
1.11
Silberschatz, Galvin and Gagne ©2005
Distributed Systems Distribute the computation among several physical processors. Loosely coupled system – each processor has its own local
memory; processors communicate with one another through various communications lines, such as high-speed buses, telephone lines, or wireless. Advantages of distributed systems. z
Resources Sharing
z
Computation speed up – load sharing
z
Reliability
z
Communications
Requires networking infrastructure. Local area networks (LAN) or Wide area networks (WAN) May be either client-server or peer-to-peer systems.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.12
Silberschatz, Galvin and Gagne ©2005
Real-Time Systems Often used as a control device in a dedicated application such as
controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems. Well-defined fixed-time constraints. Real-Time systems may be either hard or soft real-time. Hard real-time: z
Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM)
z
Conflicts with time-sharing systems, not supported by generalpurpose operating systems.
Soft real-time z
Limited utility in industrial control of robotics
z
Useful in applications (multimedia, virtual reality) requiring advanced operating-system features.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.13
Silberschatz, Galvin and Gagne ©2005
Hardware Protection Protection is needed since: z
Software error or request creates exception or trap Division
z
by zero, request for operating system service
Other process problems include infinite loop, processes modifying each other or the operating system
Dual-mode operation allows OS to protect itself and other system
components from user processes (an incorrect program cannot cause other programs to execute incorrectly) z
User mode: execution done on behalf of a user
z
kernel mode (also system mode or monitor mode): execution done on behalf of operating system.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.14
Silberschatz, Galvin and Gagne ©2005
Dual-Mode Operation Mode bit added to computer hardware to indicate the current
mode: kernel (0) or user (1). z
Provides ability to distinguish when system is running user code or kernel code
z
Some instructions designated as privileged, only executable in kernel mode
z
When an interrupt or fault occurs hardware switches to kernel mode, return from the interrupt or fault switches to user mode Interrupt/fault
kernel
user set user mode
Operating System Concepts – 7th Edition, Jan 12, 2005
1.15
Silberschatz, Galvin and Gagne ©2005
Transition from User to Kernel Mode Timer used to prevent infinite loop / process hogging resources z
Set interrupt after specific period
z
Operating system decrements counter
z
When counter zero generate an interrupt
z
Set up before scheduling process to regain control or terminate program that exceeds allotted time
Operating System Concepts – 7th Edition, Jan 12, 2005
1.16
Silberschatz, Galvin and Gagne ©2005
I/O Protection All I/O instructions are privileged instructions. Must ensure that a user program could never gain control of the
computer in kernel mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector). System calls are used to perform I/O. (later on system calls)
Operating System Concepts – 7th Edition, Jan 12, 2005
1.17
Silberschatz, Galvin and Gagne ©2005
Memory Protection In order to have memory protection,
add two registers that determine the range of legal addresses a program may access: z
Base register – holds the smallest legal physical memory address.
z
Limit register – contains the size of the range
Memory outside the defined range
is protected.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.18
Silberschatz, Galvin and Gagne ©2005
Address Protection
When executing in kernel mode, the operating system has unrestricted access to both monitor and user’s memory.
The load instructions for the base and limit registers are privileged instructions.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.19
Silberschatz, Galvin and Gagne ©2005
CPU Protection Timer – interrupts computer after specified period to ensure
operating system maintains control. z
Timer is decremented every clock tick.
z
When timer reaches the value 0, an interrupt occurs.
Timer commonly used to implement time sharing. Time also used to compute the current time. Load-timer is a privileged instruction.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.20
Silberschatz, Galvin and Gagne ©2005
User Protection and Security Protection – any mechanism for controlling access of processes or
users to resources defined by the OS
Security – defense of the system against internal and external
attacks z
Huge range, including denial-of-service, worms, viruses, identity theft, theft of service
Systems generally first distinguish among users, to determine who
can do what z
User identities (user IDs, security IDs) include name and associated number, one per user
z
User ID then associated with all files, processes of that user to determine access control
z
Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file
z
Privilege escalation allows user to change to effective ID with more rights
Operating System Concepts – 7th Edition, Jan 12, 2005
1.21
Silberschatz, Galvin and Gagne ©2005
Operating System Services One set of operating-system services provides functions that are
helpful to the user: z
User interface - Almost all operating systems have a user interface (UI) Varies
between Command-Line (CLI), Graphics User Interface (GUI), Batch
z
Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)
z
I/O operations - A running program may require I/O, which may involve a file or an I/O device.
z
File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.22
Silberschatz, Galvin and Gagne ©2005
Operating System Services (Cont.) One set of operating-system services provides functions that are
helpful to the user (Cont): z
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)
z
Error detection – OS needs to be constantly aware of 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 correct and consistent computing
Debugging
facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system
Operating System Concepts – 7th Edition, Jan 12, 2005
1.23
Silberschatz, Galvin and Gagne ©2005
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing z
Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them
Many types of resources - Some (such as CPU cycles, main memory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code.
z
Accounting - To keep track of which users use how much and what kinds of computer resources
z
Protection and security - The owners of information stored in a multi-user 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
If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.24
Silberschatz, Galvin and Gagne ©2005
User Interface - CLI Command Line Interface (CLI) allows direct command entry Sometimes
implemented in kernel, sometimes by systems
program Sometimes Primarily –
multiple flavors implemented – shells
fetches a command from user and executes it
Sometimes commands built-in, sometimes just names of programs »
If the latter, adding new features doesn’t require shell modification
Operating System Concepts – 7th Edition, Jan 12, 2005
1.25
Silberschatz, Galvin and Gagne ©2005
User Interface - GUI User-friendly desktop metaphor or graphical interface z
Usually mouse, keyboard, and monitor
z
Icons represent files, programs, actions, etc
z
Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder)
z
Invented at Xerox PARC, become widespread through Apple.
Many systems now include both CLI and GUI interfaces z
Microsoft Windows is GUI with CLI “command” shell
z
Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
Operating System Concepts – 7th Edition, Jan 12, 2005
1.26
Silberschatz, Galvin and Gagne ©2005
System Calls
Programming interface to the services provided by the OS
Typically written in a high-level language (C or C++) z
Some low-level tasks are written using assembly language.
Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use( or system call interface) z
The API specifies a set of functions that are available for the programmer.
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)
Why use APIs rather than system calls? z
Portability: the same API can run of different architectures.
z
Relief a programmer from the details and functionality of system calls.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.27
Silberschatz, Galvin and Gagne ©2005
Example of System Calls System call sequence to copy the contents of one file to another
file
Operating System Concepts – 7th Edition, Jan 12, 2005
1.28
Silberschatz, Galvin and Gagne ©2005
System Call Implementation Typically, a number associated with each system call z
System-call interface maintains a table indexed according to these numbers
The system call interface invokes intended system call in OS kernel
and returns status of the system call and any return values The caller need know nothing about how the system call is
implemented or how it works z
Just needs to obey API and understand what OS will do as a result call
z
Most details of OS interface hidden from programmer by API Managed
by run-time support library (set of functions built into libraries included with compiler) through system calls interface
Operating System Concepts – 7th Edition, Jan 12, 2005
1.29
Silberschatz, Galvin and Gagne ©2005
API – System Call – OS Relationship
Operating System Concepts – 7th Edition, Jan 12, 2005
1.30
Silberschatz, Galvin and Gagne ©2005
System Call Parameter Passing Often, more information is required than simply identity of desired
system call z
Exact type and amount of information vary according to OS and call
Three general methods used to pass parameters to the OS z
Simplest: pass the parameters in registers
z
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This
approach taken by Linux and Solaris
z
Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system
z
Block and stack methods do not limit the number or length of parameters being passed
Operating System Concepts – 7th Edition, Jan 12, 2005
1.31
Silberschatz, Galvin and Gagne ©2005
Parameter Passing via Table
Operating System Concepts – 7th Edition, Jan 12, 2005
1.32
Silberschatz, Galvin and Gagne ©2005
Standard C Library Example C program invoking printf() library call, which calls write() system call
Operating System Concepts – 7th Edition, Jan 12, 2005
1.33
Silberschatz, Galvin and Gagne ©2005
Types of System Calls Process control: end, abort, create, load, execute, wait (time,
signal), get or set process attributes….etc z
Single and multitask systems (DOS, FreeBSD)
File management: create, delete, open, close, read, write,
attributes (permission, name, type)… Device management: request, release, read, write… Information maintenance: time, date, system info Communications: z
message passing: connection must be in existence
z
shared memory: agreement is needed, no protection. Must
insure that processes don’t write to the same location simultaneously.
Operating System Concepts – 7th Edition, Jan 12, 2005
1.34
Silberschatz, Galvin and Gagne ©2005
End of Lecture 1