Title: Outline
1Outline
- Introduction to Operating Systems
- Using the Operating Systems
- The abstract model of computing
- System calls
2System Overview
- A computer system consists of hardware and
software that are combined to provide a tool to
solve specific problems - Hardware includes CPU, memory, disks, printers,
screen, keyboard, mouse ... - Software includes
- System software
- A general environment to create specific
applications - Application software
- A tool to solve a specific problem
3System Overview cont.
4Hardware Resources
- Processor execute instructions
- Memory store programs and data
- Input/output (I/O)controllers transfer to and
from devices - Disk devices long-term storage
- Other devices conversion between internal and
external data representations
5Hardware Resources cont.
6Hardware Interface cont.
- Everything that a programmer needs to know in
order to write programs that perform desired
operation on the hardware - Disk drive is an example
- Disk interface provides functions to move disk
head, transfer data - Monitor
- Monitor interface provides functions to move the
cursor, display characters/graphics
7Software Classification
- System software
- Provides a general programming environment in
which programmers can create specific
applications - Application software
- Intended to solve a specific problem
8Software Classification - continued
9What is an Operating System?
- The operating system is the part of the system
software that manages the use of the hardware
used by other system software and all application
software - It is the system program that acts between the
hardware and the user programs
10What is an Operating System? - continued
- It provides services to user programs
- Through system calls / message passing
- File system services
- Memory services
- I/O services
- It hides hardware from user programs
- When your program shows a message on the monitor,
it does not need to know the details - When your program generates a new file, it does
not need to know where the free space is on your
hard drive
11Differences between OS and System Software
- Major differences between OS and general system
software - OS abstracts the hardware directly
- General system software relies on the
abstractions provided by OS - OS provides the fundamental trusted mechanisms
for resource sharing - A general purpose OS is domain-independent
12Operating System Functions
- Resource manager
- manage hardware and software resources
- Resource abstraction and sharing
- A nicer environment
- implement a virtual machine for processes to run
in - A program in execution is called a process
- a nicer environment than the bare hardware
13Resource Management Functions
- Transform physical resources to logical resources
- Resource abstraction
- Make the hardware resources easier to use
- Multiplex one physical resource to several
logical resources - Create multiple, logical copies of resources
- Schedule physical and logical resources
- Decide who gets to use the resources
14Resource Abstraction
- Provides an abstract model of the operation of
hardware components - Like data abstraction in Object-Oriented
programming - Interface functions
- Internal functions and status
15A Disk Device Abstraction
- Three interface functions
- Load(block, length, device)
- seek(device, track)
- out(device, sector)
16A Disk Device Abstraction cont.
- An abstract function for writing
17Resource Abstraction cont.
- Multi-level abstractions
- Disk controller -gt disk driver -gt file system
18Resource Sharing
- Two types of sharing
- Time multiplexed sharing
- time-sharing
- schedule a serially-reusable resource among
several users - Space multiplexed sharing
- space-sharing
- divide a multiple-use resource up among several
users
19Time-multiplexing the Processor
- Called multiprogramming
20Time-multiplexing the Processor cont.
- Resulted in concurrent execution or concurrency
21Time-multiplexing the Processor cont.
- Multiprogramming can improve the overall system
performance
22Space-multiplexing Memory
23Time-multiplexing I/O Devices
24Space-multiplexing the Disk
25Issues in Resource Sharing
- Resource isolation and sharing
- Protection
- Sharing
- Resource allocation
- Scheduling
26Do We Need an OS?
- Not always
- When resource abstraction or sharing is not
needed - Some programs run stand-alone
- Early computers did not have a sophisticated OS
- OS was evolved along the hardware technology
- But they are very useful
- Reusable functions
- Easier to use than the bare hardware
27Operating Systems Strategies
- Several different strategies have been used
- Earliest computers were dedicated to a single
program and there was no multiprogramming and no
OS - Batch systems
- Timesharing systems
- There are a few other recent strategies
- Personal computers and workstations
- Embedded systems
- Small, communicating computers
- Network technology
28Batch Processing Systems
- Reduce setup time by batching similar jobs
- Automatic job sequencing automatically
transfers control from one job to another. First
rudimentary operating system. - Resident monitor
- initial control in monitor
- control transfers to job
- when job completes control transfers back to
monitor
29Batch Processing Systems - continued
30Memory Layout for a Simple Batch System
31Spooling
- Overlap I/O of one job with computation of
another job. While executing one job, the OS - Reads next job from card reader into a storage
area on the disk (job queue). - Outputs printout of previous job from disk to
printer. - Job pool data structure that allows the OS to
select which job to run next in order to increase
CPU utilization
32Multi-programmed Batch Systems
Several jobs are kept in main memory at the same
time, and the CPU is multiplexed among them.
33OS Features for Multi-programming
- I/O routine supplied by the system
- Memory management the system must allocate the
memory to several jobs - CPU scheduling the system must choose among
several jobs ready to run - Allocation of devices
34Time-sharing Systems
- The goal is to enable users to interact with the
computer system - Batch processing systems do not allow user
interactions - 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 not from a card reader, but rather
from the users keyboard. - On-line system must be available for users to
access data and code.
35Time-sharing Systems - continued
36Personal-computer Systems
- Personal computers computer system dedicated to
a single user. - I/O devices keyboards, mice, display screens,
small printers. - User convenience and responsiveness.
- Can adopt technology developed for larger
operating system - often individuals have sole use of computer and
do not need advanced CPU utilization of
protection features.
37Personal-computer Systems - continued
38Embedded 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.
- Hard real-time system.
- Secondary storage limited or absent, data stored
in short-term memory, or read-only memory (ROM) - Conflicts with time-sharing systems, not
supported by general-purpose operating systems. - Soft real-time system
- Limited utility in industrial control or robotics
- Useful in applications (multimedia, virtual
reality) requiring advanced operating-system
features.
39Parallel systems
- Multiprocessor systems with more than one 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
- Increased throughput
- Economical
- Increased reliability
- graceful degradation
- fail-soft systems
40Distributed 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 or telephone lines - Advantages of distributed systems
- Resources Sharing
- Computation speed up load sharing
- Reliability
- Communications
41Distributed systems - cont.
- Network operating system
- provides file sharing
- provides communication scheme
- runs independently from other computers on the
network - Distributed operating system
- less autonomy between computers
- gives the impression there is a single operating
system controlling the network.
42Migration of Operating-System Concepts and
Features
43Genesis of Modern OS
44Using the O.S.
- For a programmer, the operating system interface
is most important - The functions provided by the OS
- Abstract resources that are available
45Requesting Services from O.S.
- Two techniques
- System call
- Message passing
46Requesting Services cont.
- Two techniques
- System call
- Message passing
47System Call Interface
- System call interface
- Operating system provides a set of operations
called system calls - A programming interface
48How to Make a System Call
- For a programmer
- A system call is similar to a procedure/function
call in a traditional programming language - System calls are available in C/C as library
routines - For example, fork to create a new process
49How to Make a System Call cont.
- pid fork()
- if (pid ((pid_t)-1))
- // Something must be wrong with the fork
- // error processing
- .........
- else
- if (pid 0)
- // This is the child process
- ........
- else
- // This is the parent process
- .........
-
- //How about here, the parent or the child ?
- ...........
50System Call Overview
- man s 2 intro
- List of all the system calls available
- Process management system calls
- Memory management system calls
- File and I/O system calls
- Communication system calls
- Information maintenance system calls
51Process Management System Calls
- fork Create a new process
- exit Terminate a process
- wait Wait for a child process to terminate
- exec Execute a file
- nice Change scheduling priority for a process
- _lwp_create Create a new lightweight process
- yield Yield execution to another lightweight
process
52Thread Related Functions and System Calls
- POSIX Thread
- pthread_create
- pthread_join
- pthread_exit
- Solaris Thread
- thr_create
- thr_join
- thr_exit
53Memory Management System Calls
- brk Change the size of data segment of process
- memcntl Memory management control
- mmap Map pages of memory
- (Memory mapped I/O)
- Note malloc and free are library functions using
memory management system calls
54File Management System Calls
- open Open a file for reading or writing
- creat Create a new file and open it
- read Read bytes from an open file
- write Write bytes to an open file
- close Close an open file
- seek Change the location in the open file of
the next read or write - stat Get information about a file
- mkdir Make a directory
- mount Mount a file system
55File Management System Calls
- open Open a file for reading or writing
- creat Create a new file and open it
- read Read bytes from an open file
- write Write bytes to an open file
- close Close an open file
- seek Change the location in the open file of
the next read or write - stat Get information about a file
- mkdir Make a directory
- mount Mount a file system
An open file is a dynamic object that can provide
bytes from a file or accept bytes to be stored in
the file. It has a set attributes, such as file
pointer. It is a virtual device created by the
operating system. Files however are passive
containers of data
56I/O System Calls
- open Open a device for reading or writing
- read Read bytes from an open device
- write Write bytes to an open device
- close Close an open device
- ioctl Control device
57Communication System Calls
- pipe Create an inter-process channel
- kill Send a signal to a process or a group of
processes - msgctl Message control operations
- shmat, shmctl, shmget, shmop Shared memory
operations - Semctl, semget, semop Semaphore operations
58Information Maintenance System Calls
- acct Enable or disable process accounting
- stime Set system time and date
- times Get process and child process times
- utimes Set file times
59Interactive and Programming Interfaces
- Interactive interfaces have advantages
- for exploration
- for interactive use
- Programming interfaces have advantages
- for detailed interactions
- Inter-application programming
- Scripting
- It is useful for a program to have both interfaces
60Examples
- Shell
- Interactive interface to OS
- System calls
- Programming interface to OS
61Shell as an Interactive Interface
- Interactive access to the OS system calls and
system and user programs - cd to change current working directory
- System call is chdir
- Started by the system for a user
- Contains a simple programming language
- Popularized by UNIX
- Bourne shell, C shell (csh), Korn shell (ksh),
Bourne-again shell (bash), etc.
62Two views of a shell
63Summary
- Operating system is the system software that
controls the basic operation of a computer - The layer between the hardware and the user
programs - Resource manager manage hardware and software
resources - Goals of operating systems
- Convenience for users by providing a wide range
of functions - Efficient operation of the computer system
- Operating system provides services to user
programs through system calls - Shell as an interactive interface to system calls
and system and user programs