Lec 2 OS Fall 2023

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Operating Systems

Chapter 2: Operating-System
Structures

Reference book: Operating System Concepts, ABRAHAM SILBERSCHATZ, PETER


BAER GALVIN, Pluribus Networks, Ninth Edition, John Wiley & Sons, Inc, 2013
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
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
Operating System Debugging
Operating System Generation
System Boot

Operating System Concepts – 9th Edition 2.2 Silberschatz, Galvin and Gagne ©2013
Operating System Services
Operating systems provide an environment for execution of
programs and services to programs and users
Operating-system services offered to the user:
• User interface - Almost all operating systems have a user
interface (UI).
• Varies between Command-Line Interpreter (CLI),
Graphical User Interface (GUI), touch-screen interface,
• Program execution – OS loads the user program into memory
and run that program, end execution (normally or abnormally:
indicating error)
• I/O operations - A running program may require I/O, which
may need a file. Users usually cannot control I/O devices
directly. OS calls I/O device.

Operating System Concepts – 9th Edition 2.3 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
• File-system manipulation - Programs need to read and write
files and directories, create and delete them, search them, list
file Information, permission management.
• 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 – continuous detecting and correcting errors
• Ex.: a memory error or a power failure, a connection failure
on a network, or lack of paper in the printer, user program
arithmetic overflow
• For each type of error, OS should take the appropriate action
to ensure correct computing

Operating System Concepts – 9th Edition 2.4 Silberschatz, Galvin and Gagne ©2013
Operating System Services (Cont.)
Operating-system services offering efficient operation to
systems more than to users:

• Resource allocation - When multiple users or multiple jobs


running concurrently, resources must be properly allocated
• Ex.: how best to use the CPU, main memory, file storage, I/O
devices.
• Logging - keep track of which programs use how much and
what kinds of computer resources for accounting.
• Protection and security - owners of information in a multiuser
or networked computer system may want to control usage of
their information because concurrent processes should not
interfere with each other.

Operating System Concepts – 9th Edition 2.5 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services

A view of operating system services.

Operating System Concepts – 9th Edition 2.6 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - CLI

Command interpreter allows direct command entry


• Sometimes implemented in kernel, sometimes by systems
program
• Interpreters in systems are known as shells
• Fetches a command from user and executes it

Operating System Concepts – 9th Edition 2.7 Silberschatz, Galvin and Gagne ©2013
GUI and Touchscreen Interfaces
Graphical User Interface uses desktop interface
• Icons represent files, programs, actions,…
• Using mouse, keyboard, and monitor
• Many systems now include both CLI and GUI interfaces
• Microsoft Windows is GUI and CLI
• Apple Mac OS X is “Aqua” GUI interface
• Unix and Linux have CLI with optional GUI interfaces such as CDE,
KDE, GNOME

Touchscreen devices require new interfaces


• Mouse not possible or not desired
• based on pressing and swiping fingers across the screen
• Virtual keyboard for text entry

Operating System Concepts – 9th Edition 2.8 Silberschatz, Galvin and Gagne ©2013
System Calls
System calls are programming interface to the services provided
by the OS
• Mostly written in a high-level language (C or C++)
• Systems execute thousands of system calls per second

Ex.:
System call
sequence
to copy the contents
of one file
to another file
Figure For reading

Operating System Concepts – 9th Edition 2.9 Silberschatz, Galvin and Gagne ©2013
System Calls
System calls are mostly accessed by programs via a high-level
Application Programming Interface (API) not direct system call
• API: a set of functions available to an application
programmer, including the parameters that are passed to
each function and the return values the programmer can
expect
• The functions used inside the API by the programmer
invoke the actual system calls in the kernel
 Managed by run-time support library (set of functions built
into libraries included with compiler)
 Ex.: Win32 API for Windows, POSIX API for POSIX-based
systems, Java API
a number is associated with each system call
• Most details of OS interface hidden from programmer by API

Operating System Concepts – 9th Edition 2.10 Silberschatz, Galvin and Gagne ©2013
Example of Standard API

Operating System Concepts – 9th Edition 2.11 Silberschatz, Galvin and Gagne ©2013
API – System Call – OS Relationship

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


Figure For reading
Operating System Concepts – 9th Edition 2.12 Silberschatz, Galvin and Gagne ©2013
System Call Parameter Passing

Three general methods used to pass parameters to the OS:


• pass the parameters in registers
• Parameters stored in a block, or table, in main memory, and
address of block is passed as a parameter to a register
• Parameters are 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 – 9th Edition 2.13 Silberschatz, Galvin and Gagne ©2013
Parameter Passing via Table

Figure For reading

Operating System Concepts – 9th Edition 2.14 Silberschatz, Galvin and Gagne ©2013
Examples of Windows and Unix System Calls

For reading

Operating System Concepts – 9th Edition 2.15 Silberschatz, Galvin and Gagne ©2013
Standard C Library Example
C program invoking printf() library call, which calls write() system call
For reading

Operating System Concepts – 9th Edition 2.16 Silberschatz, Galvin and Gagne ©2013
System Services (System Utilities)
Provide a convenient environment for program development and
execution. They can be divided into:
• File manipulation
• Status information sometimes stored in a File modification
• Programming language support
• Program loading and execution
• Communications
• Background services

Operating systems are supplied with Application programs for


performing common operations, such as web browsers, word
processors and text formatters, spreadsheets, database systems,
compilers, statistical-analysis, and games.

Operating System Concepts – 9th Edition 2.17 Silberschatz, Galvin and Gagne ©2013
System Services categories
File management - Create, delete, copy, rename, print, dump, list,
and manipulate files and directories

Status information
• info - date, time, amount of available memory, disk space,
number of users
• detailed performance, logging, and debugging information

File modification
• Text editors to create and modify files
• Special commands to search contents of files or perform
transformations of the text

Operating System Concepts – 9th Edition 2.18 Silberschatz, Galvin and Gagne ©2013
System Programs (Cont.)
Programming-language support
• Compilers, assemblers, debuggers and interpreters
sometimes provided
Program loading into memory and execution
• loaders, linkage editors, and overlay-loaders, debugging
systems for higher-level and machine language
Communications
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

Operating System Concepts – 9th Edition 2.19 Silberschatz, Galvin and Gagne ©2013
System Programs (Cont.)
Background Services
• Launch at boot time and shutdown
• Disk checking, process scheduling, error logging, printing
• Run in user context not kernel context
• Known as daemons (A process which runs in the
background and is not interactive)

Application programs
• Run by users
• Not typically considered part of OS
• Launched by command line, mouse click, finger poke

Operating System Concepts – 9th Edition 2.20 Silberschatz, Galvin and Gagne ©2013
Operating System Design and Implementation

Design
Start the design by defining goals and specifications
Affected by choice of hardware, type of system
User goals and System goals:
• User goals – OS should be convenient to use, easy to learn,
reliable, safe, and fast
• System goals – OS should be easy to design, implement,
and maintain, flexible, reliable, error-free, and efficient

Implementation
• Early OS was written in assembly language, then PL/1, and
now C, C++
• Usually a mix of languages
• Systems programs are in C, C++, scripting languages like
PERL, Python, shell scripts
Operating System Concepts – 9th Edition 2.21 Silberschatz, Galvin and Gagne ©2013
Monolithic Kernel structure
Monolithic structure
A common technique for designing operating systems
places all of the functionality of the kernel into a single, static
binary file that runs in a single address space.
Tightly coupled: Difficult to implement and extend, changes to
one part of the system can have wide-ranging effects on other
parts.
Communicate with it is very fast
Ex.: Linux kernel is monolithic

Operating System Concepts – 9th Edition 2.22 Silberschatz, Galvin and Gagne ©2013
Layered Approach
Layered Approach
Loosely coupled system
Kernel is comprised of separate,
smaller components (layers) that
have specific and limited
functionality.
Changes in one component affect
only that component, and no
others
The bottom layer (layer 0), is the
hardware; the highest (layer N) is
the user interface. A layered operating system
Simplicity in construction and
debugging

Operating System Concepts – 9th Edition 2.23 Silberschatz, Galvin and Gagne ©2013
Microkernel Structure
Microkernel structure
Moves as much from the kernel into user space that reside in
separate address spaces. The result is a smaller kernel.
Ex.: Mac OS and IOS
Benefits:
• Easier to extend a microkernel
• More reliable (less code is running in kernel mode)
• More secure and reliable,
Disadv.
Performance overhead of user space to kernel space
communication

Operating System Concepts – 9th Edition 2.24 Silberschatz, Galvin and Gagne ©2013
Microkernel Structure

Application File Device user


Program System Driver mode

messages messages

Interprocess memory CPU kernel


Communication managment scheduling mode

microkernel

hardware

Operating System Concepts – 9th Edition 2.25 Silberschatz, Galvin and Gagne ©2013
Modules Structure
Loadable kernel modules
best current methodology for operating-system design
provide core services, and other services are implemented
dynamically, as the kernel is running
require recompiling the kernel every time a change was made.
Each core component is separate
More flexible than layered approach
Ex.: Linux, Solaris, etc

Operating System Concepts – 9th Edition 2.26 Silberschatz, Galvin and Gagne ©2013
Hybrid Systems
Hybrid systems combine multiple approaches to address
performance, security, usability needs
 Ex.: Linux and Solaris kernels uses single address space, so
monolithic -- very efficient performance . In addition, modular
because new functionality can be dynamically added to the
kernel
 Ex.: Windows mostly monolithic, plus microkernel
 Ex.: Apple Mac OS X is hybrid, layered,

Operating System Concepts – 9th Edition 2.27 Silberschatz, Galvin and Gagne ©2013
Mac OS and iOS
Apple’s macOS operating system runs on desktop and laptop
computer systems
• iOS runs on Apple mobile OS for iPhone, iPad

Architecture of Apple’s macOS and iOS operating systems


For reading
Operating System Concepts – 9th Edition 2.28 Silberschatz, Galvin and Gagne ©2013
Android Architecture
Android OS is Open Source while iOS is closed source
• Android is based on Linux kernel but modified
• Android Apps are developed in Java plus Android API
Applications

Application Framework

Libraries Android runtime

SQLite openGL Core Libraries

surface media
Dalvik
manager framework
virtual machine
webkit libc

Linux kernel For reading

Operating System Concepts – 9th Edition 2.29 Silberschatz, Galvin and Gagne ©2013
Operating-System Debugging
Debugging is finding and fixing errors, or bugs
• include performance tuning: improve performance by
removing processing bottlenecks
• OS generate log files containing error information
Failure of an application can generate core dump: a capture of the
memory of the process stored in a log file.
Operating system failure (in kernel) can generate crash dump

Operating System Concepts – 9th Edition 2.30 Silberschatz, Galvin and Gagne ©2013

You might also like