0% found this document useful (0 votes)
35 views

Ch02 Structures

System programs provide a convenient environment for users by offering interfaces to common tasks like file manipulation, accessing system status information, modifying files, and loading/executing programs, while hiding the underlying system calls; they define the user's view of the operating system more than the system calls themselves. Common system programs provide functionality for file management, programming language support, and communications between programs and devices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Ch02 Structures

System programs provide a convenient environment for users by offering interfaces to common tasks like file manipulation, accessing system status information, modifying files, and loading/executing programs, while hiding the underlying system calls; they define the user's view of the operating system more than the system calls themselves. Common system programs provide functionality for file management, programming language support, and communications between programs and devices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

 Operating System Services


 User Operating System Interface
 System Calls
 Types of System Calls
 System Programs
 Operating System Design and Implementation
 Operating System Structure
 Virtual Machines
 Operating System Generation
 System Boot

2.2
Objectives

 To describe the services an operating system provides to users,


processes, and other systems
 To discuss the various ways of structuring an operating system
 To explain how operating systems are installed and customized and
how they boot

2.3
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.

2.4
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

2.5
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 running
concurrently, resources must be allocated to each of them
 Many types of resources - Some (such as CPU cycles,mainmemory,
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.

2.6
User Operating System Interface - 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
– Sometimes commands built-in, sometimes just names of
programs
» If the latter, adding new features doesn’t require shell
modification

2.7
User Operating System Interface - GUI

 User-friendly desktop metaphor interface


 Usually mouse, keyboard, and monitor
 Icons represent files, programs, actions, etc.
 Various mouse buttons over objects in the interface cause various
actions (provide information, options, execute function, open
directory (known as a folder)
 Invented at Xerox PARC
 Many systems now include both CLI and GUI interfaces
 Microsoft Windows is GUI with CLI ―command‖ shell
 Apple Mac OS X as ―Aqua‖ GUI interface with UNIX kernel
underneath and shells available
 Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

2.8
System Calls

 Programming interface to the services provided by the OS


 Typically written in a high-level language (C or C++)
 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)
 Why use APIs rather than system calls?

(Note that the system-call names used throughout this text are generic)

2.9
Example of System Calls

 System call sequence to copy the contents of one file to another file

2.10
Example of Standard API
 Consider the ReadFile() function in the
 Win32 API—a function for reading from a file

 A description of the parameters passed to ReadFile()


 HANDLE file—the file to be read
 LPVOID buffer—a buffer where the data will be read into and written from
 DWORD bytesToRead—the number of bytes to be read into the buffer
 LPDWORD bytesRead—the number of bytes read during the last read
 LPOVERLAPPED ovl—indicates if overlapped I/O is being used

2.11
System Call Implementation

 Typically, 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)

2.12
API – System Call – OS Relationship

2.13
Standard C Library Example

 C program invoking printf() library call, which calls write() system call

2.14
System Call Parameter Passing

 Often, more information is required than simply identity of desired


system call
 Exact type and amount of information vary according to OS and call
 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

2.15
Parameter Passing via Table

2.16
Types of System Calls

 Process control
 File management
 Device management
 Information maintenance
 Communications

2.17
MS-DOS execution

(a) At system startup (b) running a program

2.18
FreeBSD Running Multiple Programs

2.19
System Programs

 System programs provide a convenient environment for program


development and execution. The can be divided into:
 File manipulation
 Status information
 File modification
 Programming language support
 Program loading and execution
 Communications
 Application programs
 Most users’ view of the operation system is defined by system
programs, not the actual system calls

2.20
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

2.21
System Programs (cont’d)

 File modification
 Text editors to create and modify files
 Special commands to search contents of files or perform
transformations of the text
 Programming-language support - Compilers, assemblers, debuggers
and interpreters sometimes provided
 Program loading and execution- Absolute loaders, relocatable loaders,
linkage editors, and overlay-loaders, debugging systems for higher-level
and machine language
 Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems
 Allow users to send messages to one another’s screens, browse
web pages, send electronic-mail messages, log in remotely, transfer
files from one machine to another

2.22
Operating System Design and Implementation

 Design and Implementation of OS not ―solvable‖, but some approaches


have proven successful
 Internal structure of different Operating Systems can vary widely
 Start by defining goals and specifications
 Affected by choice of hardware, type of system
 User goals and System goals
 User goals – operating system should be convenient to use, easy to
learn, reliable, safe, and fast
 System goals – operating system should be easy to design,
implement, and maintain, as well as flexible, reliable, error-free, and
efficient

2.23
Operating System Design and Implementation (Cont.)

 Important principle to separate


Policy: What will be done?
Mechanism: How to do it?
 Mechanisms determine how to do something, policies decide what will
be done
 The separation of policy from mechanism is a very important
principle, it allows maximum flexibility if policy decisions are to be
changed later

2.24
Simple Structure

 MS-DOS – written to provide the most functionality in the least space


 Not divided into modules
 Although MS-DOS has some structure, its interfaces and levels of
functionality are not well separated

2.25
MS-DOS Layer Structure

2.26
Layered Approach

 The operating system is divided into a number of layers (levels), each


built on top of lower layers. The bottom layer (layer 0), is the hardware;
the highest (layer N) is the user interface.
 With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers

2.27
Layered Operating System

2.28
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

2.29
UNIX System Structure

2.30
Microkernel System Structure

 Moves as much from the kernel into ―user‖ space


 Communication takes place between user modules using message
passing
 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

2.31
Mac OS X Structure

2.32
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
 Overall, similar to layers but with more flexible

2.33
Solaris Modular Approach

2.34
Virtual Machines

 A virtual machine takes the layered approach to its logical


conclusion. It treats hardware and the operating system
kernel as though they were all hardware
 A virtual machine provides an interface identical to the
underlying bare hardware
 The operating system creates the illusion of multiple
processes, each executing on its own processor with its own
(virtual) memory

2.35
Virtual Machines (Cont.)

 The resources of the physical computer are shared to create the virtual
machines
 CPU scheduling can create the appearance that users have their
own processor
 Spooling and a file system can provide virtual card readers and
virtual line printers
 A normal user time-sharing terminal serves as the virtual machine
operator’s console

2.36
Virtual Machines (Cont.)

Non-virtual Machine Virtual Machine

(a) Nonvirtual machine (b) virtual machine

2.37
Virtual Machines (Cont.)

 The virtual-machine concept provides complete protection of system


resources since each virtual machine is isolated from all other virtual
machines. This isolation, however, permits no direct sharing of
resources.
 A virtual-machine system is a perfect vehicle for operating-systems
research and development. System development is done on the
virtual machine, instead of on a physical machine and so does not
disrupt normal system operation.
 The virtual machine concept is difficult to implement due to the effort
required to provide an exact duplicate to the underlying machine

2.38
VMware Architecture

2.39
The Java Virtual Machine

2.40
Operating System Generation

 Operating systems are designed to run on any of a class of machines;


the system must be configured for each specific computer site
 SYSGEN program obtains information concerning the specific
configuration of the hardware system
 Booting – starting a computer by loading the kernel
 Bootstrap program – code stored in ROM that is able to locate the
kernel, load it into memory, and start its execution

2.41
System Boot

 Operating system must be made available to hardware so hardware can


start it
 Small piece of code – bootstrap loader, locates the kernel, loads it
into memory, and starts it
 Sometimes two-step process where boot block at fixed location
loads bootstrap loader
 When power initialized on system, execution starts at a fixed
memory location
 Firmware used to hold initial boot code

2.42
Types of Operating Systems

Following are some of the most widely used types of OS.


 Simple Batch System
 Multiprogramming Batch System
 Multiprocessor System
 Desktop System
 Distributed Operating System
 Clustered System
 Realtime Operating System
 Handheld System

2.43
Simple Batch Systems

 In this type of system, there is no direct interaction between user and the
computer.
 The user has to submit a job (written on cards or tape) to a computer
operator.
 Then computer operator places a batch of several jobs on an input device.
 Jobs are batched together by type of languages and requirement.
 Then a special program, the monitor, manages the execution of each
program in the batch.
 The monitor is always in the main memory and available for execution.

2.44
Simple Batch Systems

 Advantages of Simple Batch Systems


 No interaction between user and computer.
 No mechanism to prioritise the processes.

2.45
Multiprogramming Batch Systems

 In this the operating system picks up and begins to execute one of the jobs
from memory.
 Once this job needs an I/O operation operating system switches to another
job (CPU and OS always busy).
 Jobs in the memory are always less than the number of jobs on disk(Job
Pool).
 If several jobs are ready to run at the same time, then the system chooses
which one to run through the process of CPU Scheduling.

2.46
Multiprogramming Batch Systems

 In Non-multiprogrammed system, there are moments when CPU sits idle


and does not do any work.
 In Multiprogramming system, CPU will never be idle and keeps on
processing.
 Time Sharing Systems are very similar to Multiprogramming batch
systems. In fact time sharing systems are an extension of multiprogramming
systems.
 In Time sharing systems the prime focus is on minimizing the response
time, while in multiprogramming the prime focus is to maximize the CPU
usage.

2.47
Multiprogramming Batch Systems

2.48
Multiprocessor Systems

 A Multiprocessor system consists of several processors that share a


common physical memory. Multiprocessor system provides higher
computing power and speed. In multiprocessor system all processors
operate under single operating system. Multiplicity of the processors and
how they do act together are transparent to the others.

2.49
Multiprocessor Systems

 Advantages of Multiprocessor Systems


 Enhanced performance
 Execution of several tasks by different processors concurrently,
increases the system's throughput without speeding up the execution of
a single task.
 If possible, system divides task into many subtasks and then these
subtasks can be executed in parallel in different processors. Thereby
speeding up the execution of single tasks.

2.50
Desktop Systems

 Earlier, CPUs and PCs lacked the features needed to protect an operating
system from user programs. PC operating systems therefore were
neither multiuser nor multitasking. However, the goals of these operating
systems have changed with time; instead of maximizing CPU and peripheral
utilization, the systems opt for maximizing user convenience and
responsiveness. These systems are called Desktop Systems and include
PCs running Microsoft Windows and the Apple Macintosh. Operating
systems for these computers have benefited in several ways from the
development of operating systems for mainframes.

2.51
Desktop Systems

 Microcomputers were immediately able to adopt some of the technology


developed for larger operating systems. On the other hand, the hardware
costs for microcomputers are sufficiently low that individuals have sole use
of the computer, and CPU utilization is no longer a prime concern. Thus,
some of the design decisions made in operating systems for mainframes
may not be appropriate for smaller systems.

2.52
Distributed Operating System

 The motivation behind developing distributed operating systems is the


availability of powerful and inexpensive microprocessors and advances in
communication technology.
 These advancements in technology have made it possible to design and
develop distributed systems comprising of many computers that are inter
connected by communication networks. The main benefit of distributed
systems is its low price/performance ratio.

2.53
Distributed Operating System

 Advantages Distributed Operating System


 As there are multiple systems involved, user at one site can utilize the
resources of systems at other sites for resource-intensive tasks.
 Fast processing.
 Less load on the Host Machine.
 Types of Distributed Operating Systems
 Client-Server Systems
 Peer-to-Peer Systems

2.54
Distributed Operating System
 Client-Server Systems
 Centralized systems today act as server systems to satisfy requests
generated by client systems. The general structure of a client-server
system is depicted in the figure below:

2.55
Distributed Operating System
 Client-Server Systems
 Server Systems can be broadly categorized as:
 Compute Server systems, provide an interface to which clients can
send requests to perform an action, in response to which they
execute the action and send back results to the client.
 File Server systems, provide a file-system interface where clients
can create, update, read, and delete files.

2.56
Distributed Operating System
 Peer-to-Peer Systems
 The growth of computer networks - especially the Internet and World
Wide Web (WWW) – has had a profound influence on the recent
development of operating systems. When PCs were introduced in the
1970s, they were designed for personal use and were generally
considered standalone computers. With the beginning of widespread
public use of the Internet in the 1990s for electronic mail and FTP, many
PCs became connected to computer networks.

2.57
Distributed Operating System
 Peer-to-Peer Systems
 In contrast to the Tightly Coupled systems, the computer networks
used in these applications consist of a collection of processors that do
not share memory or a clock. Instead, each processor has its own local
memory. The processors communicate with one another through various
communication lines, such as high-speed buses or telephone lines.
These systems are usually referred to as loosely coupled systems ( or
distributed systems). The general structure of a client-server system is
depicted in the figure below:

2.58
Clustered Systems
 Like parallel systems, clustered systems gather together multiple CPUs to
accomplish computational work.
 Clustered systems differ from parallel systems, however, in that they are
composed of two or more individual systems coupled together.
 The definition of the term clustered is not concrete; the general accepted
definition is that clustered computers share storage and are closely linked
via LAN networking.
 Clustering is usually performed to provide high availability.

2.59
Clustered Systems
 A layer of cluster software runs on the cluster nodes. Each node can monitor
one or more of the others. If the monitored machine fails, the monitoring
machine can take ownership of its storage, and restart the application(s) that
were running on the failed machine. The failed machine can remain down,
but the users and clients of the application would only see a brief interruption
of service.

2.60
Clustered Systems
 Asymmetric Clustering - In this, one machine is in hot standby mode while
the other is running the applications. The hot standby host (machine) does
nothing but monitor the active server. If that server fails, the hot standby host
becomes the active server.
 Symmetric Clustering - In this, two or more hosts are running applications,
and they are monitoring each other. This mode is obviously more efficient,
as it uses all of the available hardware.

2.61
Clustered Systems
 Parallel Clustering - Parallel clusters allow multiple hosts to access the
same data on the shared storage. Because most operating systems lack
support for this simultaneous data access by multiple hosts, parallel clusters
are usually accomplished by special versions of software and special
releases of applications.
 Clustered technology is rapidly changing. Clustered system's usage and it's
features should expand greatly as Storage Area Networks(SANs). SANs
allow easy attachment of multiple hosts to multiple storage units. Current
clusters are usually limited to two or four hosts due to the complexity of
connecting the hosts to shared storage.

2.62
Real Time Operating System
 It is defined as an operating system known to give maximum time for each
of the critical operations that it performs, like OS calls and interrupt handling.
 The Real-Time Operating system which guarantees the maximum time for
critical operations and complete them on time are referred to as Hard Real-
Time Operating Systems.
 While the real-time operating systems that can only guarantee a maximum of
the time, i.e. the critical task will get priority over other tasks, but no assurity
of completeing it in a defined time. These systems are referred to as Soft
Real-Time Operating Systems.

2.63
Handheld Systems
 Handheld systems include Personal Digital Assistants(PDAs), such
as Palm-Pilots or Cellular Telephones with connectivity to a network such as
the Internet. They are usually of limited size due to which most handheld
devices have a small amount of memory, include slow processors, and
feature small display screens.
 Many handheld devices have between 512 KB and 8 MB of memory. As a
result, the operating system and applications must manage memory
efficiently. This includes returning all allocated memory back to the memory
manager once the memory is no longer being used.

2.64
Handheld Systems
 Currently, many handheld devices do not use virtual memory techniques,
thus forcing program developers to work within the confines of limited
physical memory.
 Processors for most handheld devices often run at a fraction of the speed of
a processor in a PC. Faster processors require more power. To include a
faster processor in a handheld device would require a larger battery that
would have to be replaced more frequently.

2.65
Handheld Systems
 The last issue confronting program designers for handheld devices is the
small display screens typically available. One approach for displaying the
content in web pages is web clipping, where only a small subset of a web
page is delivered and displayed on the handheld device.
 Some handheld devices may use wireless technology such as BlueTooth,
allowing remote access to e-mail and web browsing. Cellular
telephones with connectivity to the Internet fall into this category. Their use
continues to expand as network connections become more available and
other options such as cameras and MP3 players, expand their utility.

2.66
End of Chapter 2

You might also like