6 - Operating Systems
6 - Operating Systems
Operating Systems
Objectives
To describe the various operating system
models
Explain the operating system structures and
their functionalities
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:
● Execute user programs and make solving user problems
easier
● Make the computer system convenient to use
● Use the computer hardware in an efficient manner
What Is An Operating System?
▪ It provides computer abstraction and
arbitration.
Main Function of An Operating System
Abstraction
◦Hides details of different hardware configurations
◦Applications do not need to be tailored for each possible
device that might be present on a system
Arbitration
◦Manages access to shared hardware resources
◦Enables multiple applications to share the same
hardware simultaneously
Abstraction
Fact: Hardware devices manufactured by different manufacturer and
they have:
◦Different low-level instructions to operate
◦Different capabilities
If a common interface didn’t exist..
◦Variety of hardware might be limited
◦Every application would have to be programmed to use all
required devices
◦Example: 1990s – era computer games that required internal
programming for video and sound cards.
Solution: Operating Systems provide a common interface for
hardware devices manufactured by different manufacturers.
Arbitration
Fact: Hardware shared by multiple applications simultaneously.
◦A computer user can run several applications at a time.
◦It would be a big problem if the resources would not be allocated
according to application requests.
Solution: OS ensures that all applications can access resources
◦ Divides CPU core time among different programs
◦Manages access to RAM, I/O and disk
◦Enforces system and security policies to isolate applications from each
other.
Abstraction or Arbitration?
Supporting both Intel and AMD processors
Switching between applications
Separating memory allocated to different applications
Enabling video conferencing software to use different camera devices
Accessing two different hard disks
Sending and receiving messages over a network
Operating System Definition
■No universally accepted definition.
Operating System
Hardware
Layers of the Computer System
Application
Userspace
Hardware
Operating System Services
One set of operating-system services provides functions that are helpful to the user:
◦ User interface - Almost all operating systems have a user interface (UI)
◦ 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, end
execution, either normally or abnormally (indicating error)
◦ 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. Obviously, programs need to read and
write files and directories, create and delete them, search them, list file Information, permission
management.
A View of Operating System Services
Operating System Services
One set of operating-system services provides functions that are helpful to the user (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 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 Services
Another set of OS functions exists for 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 - 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
◦ 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
◦ 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 Structure
■Multiprogramming needed for efficiency
● Single user cannot keep CPU and I/O devices busy at all times
● Multiprogramming organizes jobs (code and data) so CPU always
has one to execute
● A subset of total jobs in system is kept in memory
● One job selected and run via job scheduling
● When it has to wait (for I/O for example), OS switches to another
job
Operating System Structure
■Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that
users can interact with each job while it is running, creating interactive computing.
● Response time should be < 1 second
● Each user has at least one program executing in memory →process
● If several jobs ready to run at the same time → CPU scheduling
● 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 Systems Operations
■Interrupt driven by hardware
■Software error or request creates exception or trap
● Division 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
Operating Systems Operations
● 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
Transition from User to Kernel Mode
■Timer to prevent infinite loop / process hogging resources
● Set interrupt after specific period
● Operating system decrements counter
● When counter zero generate an interrupt
● Set up before scheduling process to regain control or
terminate program that exceeds allotted time
Transition from User to Kernel Mode
System Calls
Programming interface to the services provided by the OS
Mostly accessed by programs via a high-level Application Program 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)
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
◦ Just needs to obey API and understand what OS will do as a result call
◦ 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)
API – System Call – OS Relationship
Types of System Calls
Process control
File management
Device management
Information maintenance
Communications
Protection
Examples of Windows and Unix System Calls
MS-DOS execution
Most users’ view of the operation system is defined by system programs, not the actual system
calls
System Programs
Provide a convenient environment for program development and execution
◦ Some of them are simply user interfaces to system calls; others are considerably more
complex
File management - Create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories
Status information
◦ Some ask the system for info - date, time, amount of available memory, disk space,
number of users
◦ Others provide detailed performance, logging, and debugging information
◦ Typically, these programs format and print the output to the terminal or other output
devices
◦ Some systems implement a registry - used to store and retrieve configuration information
System Programs (Cont.)
File modification
◦ Text editors to create and modify files
◦ Special commands to search contents of files or perform transformations of the text
With modularity, layers are selected such that each uses functions (operations) and services of only
lower-level layers
Traditional UNIX System Structure
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
Layered Structure
Technische Hogeschool Eindhoven(THE OS) – E.W Dijkstra, Netherlands
Structure
Layer Function
5 The operator
4 User programs
3 I/O management
2 Operator-process
communication
1 Memory management
0 Processor allocation and
multiprogramming
Layered Operating System
Microkernel System Structure
Moves as much from the kernel into “user” space
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
Mac OS X Structure
Modules
Most modern operating systems implement kernel modules
◦ 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
The operating system host creates the illusion that a process has its own processor and (virtual memory).
Fundamentally, multiple execution environments (different operating systems) can share the same hardware
“Open Virtual Machine Format”, standard format of virtual machines, allows a VM to run within many different
virtual machine (host) platforms
Virtual Machines (Cont.)