You are on page 1of 26

Chapter 2a: Operating-System Structures

Source: Operating System Concepts, Silberschatz, Galvin and Gagne – 10h Edition
Compiled by Samuel Banning
1.2

Outline

▪ Operating System Services


▪ User and Operating System-Interface
▪ System Calls
▪ System Services
▪ Linkers and Loaders
▪ Why Applications are Operating System Specific

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.3

Objectives

▪ Identify services provided by an operating system


▪ Illustrate how system calls are used to provide operating
system services

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.4

Introduction
▪ The operating system provides an environment for the execution of programs
▪ This is done through the provision of services

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.5

Operating System Services


▪ Operating systems provide an environment for execution of programs and services to
programs and users
▪ One set of operating-system services provides the following 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), touch-
screen, 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. Programs need
to read and write files and directories, create and delete them, search them, list file
Information, permission management.
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.6

Operating System Services (Cont.)


▪ 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

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.7

Operating System Services (Cont.)


▪ 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 run concurrently,
resources must be allocated to each of them
Many types of resources - CPU cycles, main memory, file storage, I/O devices.

• Accounting (or Logging) - 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. Also,
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

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.8

A View of Operating System Services

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.9

User Operating-System Interface

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


User Operating-System Interface
1.10

Command Line interpreter (CLI)


▪ CLI allows direct command entry
▪ Sometimes implemented in kernel, sometimes by systems
program
▪ Sometimes multiple flavors implemented – shells
▪ Primarily fetches a command from user and executes it
▪ These commands can be implemented in two general ways:
• the command interpreter itself contains the code to
execute the command
• implements most commands through system programs
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
User Operating-System Interface
1.11

Graphical User Interfaces


▪ Rather than entering commands directly via a command-line
interface, the GUI employs a mouse-based window-and-
menu system characterized by a desktop metaphor
▪ GUI first appeared in early 1970s at Xerox PARC research
facility.
▪ The first GUI appeared on the Xerox Alto computer in 1973.
▪ GUI became more widespread with the advent of Apple
Macintosh in the 1980s
▪ Microsoft’s first version of Windows—Version 1.0—was
based on the addition of a GUI interface to the MS-DOS
operating system (CLI). Xerox Alto (source: Wikipedia)

▪ Unix and Linux have CLI with optional GUI interfaces (CDE,
KDE, GNOME)
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.12

System Calls

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.13

System Calls

▪ System calls provide an


interface to the operating
system services
▪ Typically written in high-level
languages, such as C and
C++
▪ Let’s discuss this example
program: a simple program to
copy files
▪ Frequently, systems execute
thousands of system calls per
second.

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.14

▪ Most programmers never see this level of detail.


▪ Application developers design programs according to an Application
Programming Interface (API).
▪ The API specifies a set of functions that are available to an application
programmer, including the parameters that are passed to each function and the
return values the programmer can expect
▪ Three of the most common APIs available to application programmers:
• Win32 API for Windows systems,
• the POSIX API for POSIX-based systems (which include virtually all versions of
UNIX, Linux, and Mac OS X), and
• the Java API for designing programs that run on the Java virtual machine
▪ The API invokes the actual system calls on behalf of the application programmer
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.15

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.16

▪ Why would an application programmer prefer programming according to an API rather


than invoking actual system calls?
1. program portability: using an API, a programmer can expect her program to compile
and run on any system that supports the same API
2. actual system calls can often be more detailed and difficult to work with than the API
available to an application programmer.
▪ Compilers have a set of functions built into their libraries called run-time support system
▪ This run-time support system provides a system-call interface that serves as the link
to the OS system calls
▪ The system-call interface intercepts function calls in the API and invokes the
necessary system calls within the operating system
▪ Thus, most of the details of the operating-system interface are hidden from the
programmer by the API and are managed by the run-time support library

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.17

The handling of
a user
application
invoking the
open() system
call

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.18

Types of System Calls

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.19

▪ System calls can be grouped roughly into six major


categories:
1.process control,
2.file manipulation,
3.device manipulation,
4.information maintenance,
5.communications, and
6.protection.
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.20

Types of System Calls


▪ Process control
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.21

Types of System Calls . . . )


▪ File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
▪ Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.22

Types of System Calls . . .


▪ Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
▪ Communications
• create, delete communication connection
• send, receive messages if message passing model to host name or process
name
From client to server
• Shared-memory model create and gain access to memory regions
• transfer status information
• attach and detach remote devices
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.23

Types of System Calls . . .

▪Protection
•Control access to resources
•Get and set permissions
•Allow and deny user access
Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning
1.24

Examples of Windows and Unix System Calls

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


1.25

Why Applications are Operating System Specific

▪ Apps compiled on one system usually not executable on other


operating systems
▪ Each operating system provides its own unique system calls
• Own file formats, etc.
▪ Apps can be multi-operating system
• Written in interpreted language like Python, Ruby, and interpreter
available on multiple operating systems
• App written in language that includes a VM containing the running
app (like Java)
• Use standard language (like C), compile separately on each
operating system to run on each
▪ Application Binary Interface (ABI) is architecture equivalent of API,
defines how different components of binary code can interface for a
given operating system on a given architecture, CPU, etc.

Silberschatz, et al, Operating System Concepts Compiled by: Samuel Banning


End of Chapter 2a

Source: Operating System Concepts, Silberschatz, Galvin and Gagne – 10h Edition
Compiled by Samuel Banning

You might also like