Operating Systems - The College of Saint Rose
Download
Report
Transcript Operating Systems - The College of Saint Rose
Operating
Systems
CIS 432
David Goldschmidt, Ph.D.
Computer Science
The College of Saint Rose
Operating System Services
An operating system provides services to its users:
Program execution
I/O operations
Load programs into memory, run/suspend/halt programs,
handle/display errors
Seamlessly interact with I/O devices, including
disks, networks connection, etc.
Filesystem manipulation
Read/write/traverse filesystem directories,
read/write files, enforce permissions, search for files, etc.
Operating System Services
Other services an operating system provides:
Inter-Process Communications (IPC)
Processes exchange information via shared memory,
message passing, sockets, pipes, files, etc.
Might span multiple computer systems
Error detection and recovery
Errors arise in CPU, memory, I/O devices,
processes, etc.
Operating system should detect and recover from errors,
ensuring correct and consistent operations
Operating System Structure
Using a layered approach, the operating system is
divided into N levels or layers
Layer 0 is the hardware
Layer N is the top-level
user interface
Each layer uses functions
and services of lower layers
Layer 1 often is the kernel
Operating System Structure
Operating System Kernel
The core program running in an
operating system is the kernel
When a computer is switched on,
a bootstrap program executes from ROM
Bootstrap program initializes all aspects of the system,
then loads the operating system kernel and starts its
execution
User and Kernel Modes
Dual-mode operation provides a user mode and
a kernel mode of operation
Allows the operating system to protect itself and other
system components
User and Kernel Modes
Kernel relinquishes control to a user process,
but may set a timer to ensure a process does not
run beyond its allotted time
Avoid infinite loops, memory leaks, memory hogs, etc.
Not entirely effective in practice?
How many times have you fought to stop a runaway process?
Kernel also provides security
via privileged instructions
System Calls via APIs
Operating system services available to users
via GUI and CLI, which are just software programs
System calls are made via programming interface
called an Application Program Interface (API)
Common operating system APIs:
Win32 API for Windows
POSIX API for POSIX-based systems,
including UNIX, Linux, Mac OS X
Java API for Java Virtual Machine
C++ Standard Library
System Calls via APIs
Types of system calls include:
Process control (e.g. start/suspend/stop a process)
File management
Device management
Information retrieval and maintenance
Debugging information, too
Current date/time, number of current users, OS version,
amount of free memory, process information, etc.
Communications (e.g. IPC, network)
System Calls via APIs
System call sequence for a file copy program:
System Calls via APIs
An API successfully hides the implementation details
of the operating system
Programmers just need to abide by
the API specifications
Change the operating system,
but maintain the API such that
it is backwards compatible
Deprecate old behavior over
long period of time
Why?
hey, the dude
abides, man
System Calls via APIs
System Calls via APIs
Example using the
printf() function
from C
One API may call
another, which may
call another, etc.
System Calls via APIs
Pass parameters to the operating system
via registers or a block of data in memory