Lecture 2
Lecture 2
Lecture 2
Operating System Concepts – 7th Edition, Jan 12, 2005 1.1 Silberschatz, Galvin and Gagne ©2005
Chapter 2: Operating System Structures
Operating System Concepts – 7th Edition, Jan 12, 2005 1.2 Silberschatz, Galvin and Gagne ©2005
Operating System Services
Operating System Concepts – 7th Edition, Jan 12, 2005 1.3 Silberschatz, Galvin and Gagne ©2005
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. The program must be able to end its
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.
Operating System Concepts – 7th Edition, Jan 12, 2005 1.5 Silberschatz, Galvin and Gagne ©2005
Operating System Services (Cont.)
Another set of operating system services are used for ensuring the
efficient operation of the system itself via resource sharing
Operating System Concepts – 7th Edition, Jan 12, 2005 1.6 Silberschatz, Galvin and Gagne ©2005
User Operating System Interface
Operating System Concepts – 7th Edition, Jan 12, 2005 1.7 Silberschatz, Galvin and Gagne ©2005
The Command Line Interface
There are two fundamental approaches for users to interface with the
operating system: command line interface and graphical user interface
The command line interface, or command interpreter, allows users to
directly enter commands to be performed by the operating system
Some operating systems include the command interpreter in the kernel.
Others, such as Windows and UNIX, treat the command interpreter as a
special program that is running when a job is initiated or when a user first logs
on
Part of the interface is implemented in the form of a single shell program; the
other part is implemented as system programs
The main function of the command interpreter is to get and execute the next
user-specified command
Operating System Concepts – 7th Edition, Jan 12, 2005 1.8 Silberschatz, Galvin and Gagne ©2005
The Graphical User Interface (GUI)
A graphical user interface (GUI) provides a mouse-based interface
consisting of windows and menus
Depending on the position of the mouse cursor, clicking on a
mouse button can invoke a program, select a file or directory, or
pull down a menu that contains commands
Graphical user interfaces first appeared because of the research
that took place in the early 1970s at the Xerox PARC research
facility
Many systems now include both CLI and GUI interfaces
Microsoft Windows is GUI with CLI “command” shell
Solaris is CLI with optional GUI interfaces
Operating System Concepts – 7th Edition, Jan 12, 2005 1.9 Silberschatz, Galvin and Gagne ©2005
Choice of Interface
The choice of whether to use a command-line or GUI interface is
mostly one of personal preference.
System administrators who manage computers have deep knowledge
of a system frequently use the command-line interface.
For them, it is more efficient, giving them faster access to the activities
they need to perform.
In contrast, most Windows users are happy to use the Windows GUI
environment and almost never use the MS-DOS shell interface.
The user interface can vary from system to system and even from user
to user within a system
Operating System Concepts – 7th Edition, Jan 12, 2005 1.10 Silberschatz, Galvin and Gagne ©2005
System Calls
Operating System Concepts – 7th Edition, Jan 12, 2005 1.11 Silberschatz, Galvin and Gagne ©2005
System Calls
Systems calls provide an interface to the services made available by an
OS
These calls are generally available as routines written in a high-level
language (C or C++)
Certain low-level tasks (for example, tasks where hardware must be
accessed directly) may have to be written using assembly-language
instructions
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)
Java API for the Java virtual machine (JVM)
Operating System Concepts – 7th Edition, Jan 12, 2005 1.12 Silberschatz, Galvin and Gagne ©2005
Example of System Calls
Below is a sequence of system calls to copy the contents of one file
to another file
Operating System Concepts – 7th Edition, Jan 12, 2005 1.13 Silberschatz, Galvin and Gagne ©2005
System Call Implementation
Typically, there is a number associated with each system call
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
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)
Operating System Concepts – 7th Edition, Jan 12, 2005 1.14 Silberschatz, Galvin and Gagne ©2005
API – System Call – OS Relationship
Operating System Concepts – 7th Edition, Jan 12, 2005 1.15 Silberschatz, Galvin and Gagne ©2005
Standard C Library Example
C program invoking printf() library call, which calls the write() system call
Operating System Concepts – 7th Edition, Jan 12, 2005 1.16 Silberschatz, Galvin and Gagne ©2005
System Call Parameter Passing
Three general methods used to pass parameters to the OS
Simplest: pass the parameters in registers
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
Parameters placed, or pushed, onto the stack by the
program and popped off the stack by the operating
system
Block and stack methods do not limit the number or
length of parameters being passed
Operating System Concepts – 7th Edition, Jan 12, 2005 1.17 Silberschatz, Galvin and Gagne ©2005
Parameter Passing via Table
Operating System Concepts – 7th Edition, Jan 12, 2005 1.18 Silberschatz, Galvin and Gagne ©2005
Types of System Calls
Operating System Concepts – 7th Edition, Jan 12, 2005 1.19 Silberschatz, Galvin and Gagne ©2005
Five Major Categories
System calls can be grouped into five major categories:
Process control
Load, execute, end, abort, create process, get/set process
attributes, wait for time/signal, allocate/free memory
File management (manipulation)
Create/delete/open/close/read/write a file, get/set file attributes
Device management
Request/release device, read/write data, get/set attributes
Information maintenance
Get/set time or date, get/set system data, get/set attributes for
process/file/device
Communications
Create/delete connection, send/receive messages, attach/detach
devices
Operating System Concepts – 7th Edition, Jan 12, 2005 1.20 Silberschatz, Galvin and Gagne ©2005
Example of MS-DOS execution
Operating System Concepts – 7th Edition, Jan 12, 2005 1.21 Silberschatz, Galvin and Gagne ©2005
Example of LINUX Running Multiple Programs
Operating System Concepts – 7th Edition, Jan 12, 2005 1.22 Silberschatz, Galvin and Gagne ©2005
System Programs
Operating System Concepts – 7th Edition, Jan 12, 2005 1.23 Silberschatz, Galvin and Gagne ©2005
System Program Categories
Operating System Concepts – 7th Edition, Jan 12, 2005 1.24 Silberschatz, Galvin and Gagne ©2005
Operating System Design and
Implementation
Operating System Concepts – 7th Edition, Jan 12, 2005 1.25 Silberschatz, Galvin and Gagne ©2005
Operating System Design and Implementation
Operating System Concepts – 7th Edition, Jan 12, 2005 1.26 Silberschatz, Galvin and Gagne ©2005
Operating System Design and Implementation (Cont.)
Mechanisms and Policies
One important principle is the separation of policy from mechanism.
Mechanisms determine how to do something; policies determine
what will be done.
For example, the timer construct is a mechanism for ensuring CPU
protection, but deciding how long the timer is to be set for a particular
user is a policy decision.
The separation of policy and mechanism is important for flexibility.
Policies are likely to change across places or over time.
In the worst case, each change in policy would require a change in the
underlying mechanism.
A general mechanism insensitive to changes in policy would be more
desirable.
A change in policy would then require redefinition of only certain
parameters of the system.
Operating System Concepts – 7th Edition, Jan 12, 2005 1.27 Silberschatz, Galvin and Gagne ©2005
Operating System Structure
Operating System Concepts – 7th Edition, Jan 12, 2005 1.28 Silberschatz, Galvin and Gagne ©2005
29
Monolithic Architecture
Operating System Concepts – 7th Edition, Jan 12, 2005 1.29 Silberschatz, Galvin and Gagne ©2005
30
Layered Architecture
Operating System Concepts – 7th Edition, Jan 12, 2005 1.30 Silberschatz, Galvin and Gagne ©2005
Layered Approach …
Operating System Concepts – 7th Edition, Jan 12, 2005 1.32 Silberschatz, Galvin and Gagne ©2005
End of Introduction
Operating System Concepts – 7th Edition, Jan 12, 2005 1.33 Silberschatz, Galvin and Gagne ©2005