Professional Documents
Culture Documents
Lec 2 OS Fall 2023
Lec 2 OS Fall 2023
Lec 2 OS Fall 2023
Chapter 2: Operating-System
Structures
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:
Operating System Concepts – 9th Edition 2.5 Silberschatz, Galvin and Gagne ©2013
A View of Operating System Services
Operating System Concepts – 9th Edition 2.6 Silberschatz, Galvin and Gagne ©2013
User Operating System Interface - CLI
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
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
Operating System Concepts – 9th Edition 2.13 Silberschatz, Galvin and Gagne ©2013
Parameter Passing via Table
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 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
messages messages
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
Application Framework
surface media
Dalvik
manager framework
virtual machine
webkit libc
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