ICS 431 Ch1 2 OS Intensive Introduction
ICS 431 Ch1 2 OS Intensive Introduction
ICS 431 Ch1 2 OS Intensive Introduction
• In today’s class,
Operating System
Operating System
Controls the hardware and coordinates its use among the various application programs for the various user.
Computer Hardware
– …..
As we are going to study the OS, we should think about the followings:
– Structure: How are the OS components organized?
– Sharing: How are resources shared across users/processes?
– Concurrency: How are concurrent processes (computation and I/O)
created and controlled?
– Naming: How are resources named (by users or processes)?
– Communication: How do processes exchange information, including
across network?
– Security: How is the integrity of the OS and its resources ensured?
– Accounting: How do we keep track of a resource usage, and perhaps
charge for it?
– Performance: How do we make it all go fast to improve the
responsiveness.
– Reliability: What happens if something goes wrong (either with hardware
or with a program)?
– Extensibility: Can we add new features into the OS?
– Scale: What happens as demands or resources increase?
– Distribution: How do multiple computers interact with each other?
• Program execution: the OS allows the system to load a program into memory
(where, when, and how long?) and to execute it.
• I/O operations: Since user programs cannot execute I/O operations directly,
the OS must provide some means to perform I/O.
• File-system manipulation: the OS allows programs to read and write files and
directories, to create and delete them, to search for them, to list file
Information, etc.
• Communications: the OS allows processes executing either on the same
computer or on different systems tied together by a network to exchange
information. Implemented via shared memory or through message passing.
Since the OS is like a library with a well defined set of API’s. The application
programmer’s interest revolves mainly around:
• What abstractions are available from the OS?
– Don’t want to keep rewriting the same program for each new OS
release.
• Since, the OS is a program that allows the efficient and fair usage of
resources. The system administrator’s interest revolves mainly
around:
Advantage:
• The virtual-machine concept provides complete protection of system
resources since each virtual machine is isolated from all other virtual
machines.
• Allows you to install different platforms on the same machine.
Disadvantage:
• The isolation, however, permits no direct sharing of resources.
• That means the resources utilization will be low and the throughput will be
low as well.
• The virtual machine concept is difficult to implement due to the effort
required to provide an exact duplicate to the underlying machine.
disk disk
Processors Processors
disk disk
Network
node 3 node N
Processors disk … disk
Processors
disk disk
• The main objective here is to discuss how the operating support of each
computing model will be different.
Dr. Tarek Helmy, KFUPM-ICS 41
Client-Server Computing Model
by clients
• Server computer provides an
interface to the clients to request
services (i.e. database).
• File-server provides interface for
clients to store and retrieve files.
result result
Server
Client
Key:
Proces s: Computer:
• Advantages:
– Centralization: access, resources, and data security are
controlled through the server.
– Scalability: any element can be upgraded when needed.
– Flexibility: new technology can be easily integrated into the
system.
– Interoperability: all components (clients, network, servers) work
together.
– Accessibility: server can be accessed remotely and across
multiple platforms
– Lower costs
• Disadvantages
– If the number of simultaneous client requests to a given server
increases, the server becomes overloaded.
– Lacking of the robustness, if the server fails, clients’ requests
cannot be fulfilled.
Dr. Tarek Helmy, KFUPM-ICS 43
Peer-to-Peer Computing Model
• Advantages
– No central point of failure
• All peers in P2P network are the same.
• Data and computation is decentralized/not centralized.
• Peers are autonomous, they have full control.
– Scalability
• Since every peer is alike, it is possible to add more peers to the
system and scale it to larger networks.
• Disadvantages
– Decentralized coordination
• How to keep the global state consistent?
• Require distributed coherency protocols.
– All node’s load may not be equal, Load unbalance.
• Computing power, bandwidth have an impact on overall
performance.
• Web has become everywhere and available all the time (Ubiquity)
• Computing-intensive applications need more computing and better performance.
• Cloud computing is an Internet-based computing, where shared resources, software
and information are provided to computers and other devices on-demand, like the
electricity grid.
• Cloud computing is a model for enabling convenient, on-demand network access to
a shared pool of configurable computing resources (e.g., networks, servers, storage,
applications, and services) that can be rapidly released with minimal management
effort.
• Cloud computing is a way of managing large numbers of highly virtualized
resources such that, from a management perspective, they resemble a single large
resource. This can then be used to deliver services with flexible scaling.
• Cloud Providers – Amazon, Google, e.g. Google owns more than 20,000 servers/data
center.
• In most systems, processes form a tree, with the root (parent) being the
first process to be created.
• An example of a process tree:
– A created two children processes, B and C
• B created three children processes, D, E, and F
• We will get into the details of the process management in Ch. 3 soon.
Dr. Tarek Helmy, KFUPM-ICS 49
Main-Memory Management Component (MMMC)
• The MMMC in the operating system is responsible for the following activities
in connections with the main memory management:
– The MMMC keeps track of which parts of the main memory are currently
used and which parts are free.
– The MMMC decides which processes to load when memory space
becomes available.
• A policy is needed
– The MMMC decides how many block of memory to allocate to each
process.
• A policy is needed
– The MMMC maintains the mappings of processes from physical to virtual
memory and vise versa.
• Through page tables
– The MMMC decides when to remove/eject out a process from memory if
memory space it required by a VIP process.
• A policy is needed
• We will get into the details of the main memory management in Ch. 8 soon.
• File Management
– A file in windows OS is a collection of related information defined
by its creator. Files represent programs (both data, source, object
and executable forms).
– In Unix/Linux files are either ordinary files (doc., exe., pdf., media,
etc.), directory files (folders) or devise file (printers, CD, ..)
– The FMC is responsible for the following activities in connections
with the file management:
• File creation and deletion.
• Directory creation and deletion.
• Support of primitives for manipulating files and directories.
• Mapping files onto secondary storage.
• File backup on stable (nonvolatile) storage media.
• We will get into the details of the file management in CHs. 13 &14
soon.
Dr. Tarek Helmy, KFUPM-ICS 51
I/O Management Component (IOMC)
• We will present the details of I/O management in the intensive introduction & you need to
read Ch.12.
• The details of NMC will be introduced in the network and distributed systems
Chapter19. (not covered in the undergraduate course.
Base Base+Limit
Memory
CPU >= <
Address Yes Yes
(user mode) No No
Trap to OS
(Addressing error)
Fast Expensive
– Cost
– Volatility
– Size
Memory
Slow Cheap
• CPU registers (index registers, ACC, etc.)
provides a high speed cache for CPU.
• Caching
– Use of high-speed memory to hold recently-accessed data.
– Requires a cache management policy (cache size, replacement policy).
– Data that resides on the disk are copied into the main memory, then into the
cache and then into the CPU registers for processing.
– This requires data that is simultaneously stored in more than one level to be
consistent.
– Consistency: due to replication of data, this may lead to one copy being
different from the others. The OS must insure that all copies of the data will be
the same.
– This is not a big problem, in computing environment where only one process
executes at a time. The modification done on the CPU registers can be copied
back to the disk for a consistency purpose.
– In multiprocessing environment, extreme care must be taken by the OS so
that if several processes want to access A, then each should get the latest
value of A.
Monitor User
Mode Mode
• Modern OSs are events-driven programs where events are either Interrupts or
Exceptions.
• Interrupts are used to handle events external to the processor, raised by
hardware devices or from the process to OS (system call) to get OS
attention. Interrupts are not visible to the user’s programs, e.g.:
• A device finishes I/O operation (keyboards, mouse, etc. ).
• Timer fires
• Exceptions or traps are used to handle events internal to the processor
(detected by the processor while executing the process), means caused by
software and it is visible to the user’s programs, e.g.:
• An exception e.g., “div. by zero”
• A page fault, “write to a read-only page”
• Asking to make arithmetic operation on non-numbers.
• The Interrupts transfer the control to the interrupt service routine, through the
interrupt vectors which contain the addresses of all the service routines.
Processor
Processor Interrupt
Exception
4. If the user’s process does not have a specified handler, then the OS
suspends it and runs the OS’s exception handler routine.
Synchronous Asynchronous
Device-Status Table
• Fast I/O devices (graphics cards, network cards and sound cards,
etc.) use Direct Memory Access (DMA), why?
CPU sends read
• DMA permits the I/O device to transfer data directly to or from request to DMA
main memory without having each byte handled by the CPU. unit
• System calls allow user’s processes to request some services from the
operating system which the process itself is not allowed to do.
• A System call: Provides a "direct access" to OS services (e.g., file system,
I/O routines, memory allocate & free routines) by user’s processes.
• System calls in fact, are treated as a special case of interrupts.
• Programs that make system calls called "system programs“.
• System calls accessed by system programs via Application Program
Interface (API).
• Three most common APIs are Win32 API for Windows, POSIX API UNIX,
Linux, Mac OS X, and Java API for the Java Virtual Machine (JVM).
• System calls sequence to copy the contents of one file to another file.
OSs execute
Even simple thousands of
programs may system calls per
make heavy second.
use of the OS.
Kernel Mode
mode bit = 0
System Calls
Number Pointer
open()
• Implementation of The system call
interface
• A number is
the open() system
intercepts function
call.
• associated . calls in the API
i . and invokes the
with each necessary system
.
• system call. calls made
• return available within
the operating
• system.
• The system programs are a set of utility programs help the process to issue a
system call requesting services.
• System programs were traditionally coded in assembly language but currently
written by C, C++, and Java Programming languages.
• Example of System Program:
• File management: Create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.
• Status information: Asks the system for info. i.e. date, time, amount of
available memory, disk space, number of users
• File Processing: Text editors to create, modify and search contents of files.
• Programming-language support: Compilers, assemblers, debuggers and
interpreters.
• Program loading and execution: Absolute 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 (http, ftp, telnet, …)
– Allow users to send messages to one another’s, browse web pages, send
electronic-mail messages, log in remotely, files transfer.
• Three methods are used to pass system call parameters to the OS:-
The methods to pass parameters between a running program and the OS.
• Consider the ReadFile() system call in the Win32 API for reading from a file
Message-Passing Shared-Memory
• Messages can be exchanged • Processes can communicate
between processes either directly or by reading and writning to
indirectly using a common mailbox. shared memory.
• Flexibility
– It should be easy to add and remove functional modules from the operating
system. This is the idea of microkernel operating system. In a microkernel
operating system, it provides minimal services:
• Inter-Process communications (IPC)
• Some memory management
• A limited amount of low-level process management and scheduling.
• Low-level input/output.
– These basic services are provided in kernel just because it is too expensive
to provide them anywhere else.
• Reliability
– With distributed system, it is possible to provide higher reliability because
some nodes can perform functions for the failed nodes.
• Performance
– With distributed systems, one expects better performance.
• Scalability
– The system design should be able to expand to large number of
processors, not just a few.
• Major advantage:
– Cost of module interactions is low (procedure/function/method call)
• Disadvantages:
– Hard to understand,
• Benefits:
– Easier to extend a microkernel,
– Easier to port the operating system to new architectures,
– More reliable (less code is running in kernel mode),
• Disadvantages:
– Performance overhead of user space to kernel space communication.
Mac OS X Structure
• Can we organize the OS into layers in order to simplify its design and implementation?
• Advantages:
– Each layer can be tested and verified independently,
– Layering eases maintenance, developing, and updating of
system,
– Explicit structure allows identification, relationship of complex
system’s pieces.
• Disadvantages:
• Disjunction between modularity and reality
– Systems modeled as layers, but not really built that way.
• Strict layering isn’t flexible enough
– A layer can communicate only with the lower layer.
• Poor performance
– Each layer crossing has overhead associated with it.
• A modular operating system is built with its various functions broken up into
distinct processes, each with its own interface.
• Most modern operating systems implement the kernel as modules
– Uses object-oriented approach,
– kernel does not have to implement message passing since
modules/Functions are free to contact each other directly.
– 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 flexibility
Advantages:
• The virtual-machine concept provides complete protection of
system resources since each virtual machine is isolated from all
other virtual machines.
Disadvantage:
• The isolation, however, permits no direct sharing of resources
which is against sharing of the resources to maximize their
utilization.
• The virtual machine concept is difficult to implement due to the
effort required to provide an exact duplicate to the underlying
machine.
• Since the OS is designed to run on any machine; the OS must be configured for each
computer, this process is known as system generation.
• Sysgen is the process of creating a particular unique instance of an OS by combining
user-specified options and parameters with manufacturer-supplied general-purpose
program code to produce an OS tailored for a particular hardware and software
environment.
• SYSGEN Module obtains information concerning the specific configuration of the
hardware system, it may ask the system operator to define the HW or probes the HW
directly. SYSGEN must determine:
– What type of the CPU? Type of instruction set, floating point arithmetic, ..
– How much memory is available? Some OS will detect the amount of memory by
referencing the memory locations sequentially until getting into illegal address.
– What devices are available? The OS needs to know how to address each device,
the characteristic of the device, etc.
– Any newly connected HWs can be used through Plug and play feature.
• After the OS is generated, it must be available for the use by the HW through:
• Bootstrap program/BIOS: Code stored in ROM that is able to locate the kernel, to load
it into memory, and to start its execution.
• Booting: The procedure of starting a computer by loading the fundamental parts
(kernel) of the OS.
Thank you
Any Questions?