Lectures 1&2
Fundamentals
of
Operating System
By:
Dr. Hajar Esmaeil As-Suhbani
Cyber Security, 2nd Level
Outline
What is the Operating System?
Operating System Components
Storage Structure
User Interface
Different types of OS
OS services
System calls
System programs
OS structure
2
What is the Operating System?
Computer System = Hardware + Software
Software = Application Software + System Software(OS)
An operating system is: A program that manages the computer
hardware.
It also provides a basis for application programs and acts as an
intermediary/ interface between the user of the computer and
the computer hardware.
Operating system goals:
Execute user programs and make solving user problems easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner
3
Computer-System Components
Computer system can be divided into four components:
Hardware: provides basic computing
resources.
CPU, memory, I/O devices
Operating system: Controls and
coordinates use of hardware among
various applications and users
Application programs: Define the
ways in which the system resources are
used to solve the computing problems of
the users.
Word processors, compilers, web
browsers, database systems, video
games
Users: People, machines, other
Figure 1.1 Abstract view of the components of a computer
computers. system.
4
Operating System Definition
To understand more fully the operating system from role, we explore
operating systems from two viewpoints:
User view: OS is an interface
Makes interfacing with the computer and running applications easy.
System view: OS is resource allocator
Controls and coordinates the hardware resources, services the
application software (controls execution of programs to prevent
errors ).
5
Some Important Terms
Kernel:
Kernel is a software code that reside in central core of OS.
It has complete control over system.
When operation system boots, kernel is first part of OS to load in main
memory.
Kernel remains in main memory for entire duration of computer session.
Bootstrap program:
For a computer to start running it needs to have an initial program to
run.
Bootstrap program is loaded at power-up or reboot
Typically stored in ROM or EPROM, generally known as firmware
Initializes all aspects of system
Loads operating system kernel and starts execution.
6
Power On Switch sends electricity to the motherboard on a wire called the Voltage Good line.
If the power supply is good, then the BIOS (Basic Input/Output System) chip takes over.
In Real Mode, CPU is only capable of using approximately 1 MB of memory built into the
motherboard.
The BIOS will do a Power-On Self Test (POST) to make sure that all hardware are working.
BIOS will then look for a small sector at the very beginning of your primary hard disk called MBR.
The MBR contains a list, or map, of all of the partitions on your computer‘s hard disk (or disks).
After the MBR is found the Bootstrap Loader follows basic instructions for starting up the rest of
the computer, including the operating system.
In Early Kernel Initialization stage, a smaller core of the Kernel is activated.
This core includes the device drivers needed to use computer‘s RAM chips.
7
Storage Structure
Storage systems organized in hierarchy in terms of:
Volatile
Speed
Cost Smaller
size Loses its
Volatility
contents when
• Expensive but fast power is
removed
• Cost per bit decreases
Larger Nonvolatile
size
Retains its
contents even
• Access time increases when power is
removed
8
…Storage Structure
Registers – used to store small piece of information (8, 32, 64 bits).
Cache – (access speed is very fast), used to store frequently used
instructions e.g., For loop.
Main memory – only large storage media that the CPU can access
directly.
Random access
Typically volatile
Various technologies becoming more popular
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity.
Solid-state disks – faster than hard disks, nonvolatile.
Hard disks – rigid metal or glass platters covered with magnetic
recording material.
Magnetic tapes – used on the olden days (obsolete).
9
User Interface
A user interface (UI) controls how you 2. Graphical user Interface
enter data and instructions and how With a graphical user interface (GUI),
information is displayed on the screen you interact with menus and visual
There are three types of user interfaces: images.
1. Command Line Interface
In a command-line interface, a user
types commands represented by short
keywords or abbreviations or presses
special keys on the keyboard to enter 3. Touch screen devices require new
data and instructions. interfaces
• Here, users interact by making gestures
on the touchscreen—for example,
pressing and swiping fingers across the
screen.
10
Types of OS
There are several types of Operating Systems in which many of which are
mentioned below:
Batch Operating System
Multi-Programming System
Multi-Processing System
Multi-Tasking Operating System
Time-Sharing Operating System
Distributed Operating System
Network Operating System
Real-Time Operating System
11
Types of OS:
Batch Operating System
This type of operating system does not interact with the computer directly.
There is an operator which takes similar jobs having the same requirement
and groups them into batches.
It is the responsibility of the operator to sort jobs with similar needs.
Examples of Batch Operating Systems: Payroll Systems, Bank Statements,
etc.
12
Types of OS:
Multiprocessors
Multi-Processing Operating System is a type of Operating System in which
more than one CPU is used for the execution of resources.
Also known as parallel systems, tightly-coupled systems
Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability: As it has several processors, so, if one
processor fails, we can proceed with another processor.
Two types:
Asymmetric Multiprocessing – each processor is assigned a
specific task (Sun's operating system SunOS Version 4 provided
asymmetric multiprocessing).
Symmetric Multiprocessing – each processor performs all tasks
(Version 5 (Solaris) is symmetric on thesame hardware).
13
Types of OS:
Clustered Systems
Like multiprocessor systems, but multiple systems working together
Some cluster products support dozens of systems in a cluster, as well as
clustered nodes that are separated by miles.
Usually sharing storage via a storage-area network (SAN)
Provides a high-availability service which survives failures
Asymmetric clustering has one machine in hot-standby mode.
Symmetric clustering has multiple nodes running applications,
monitoring each other.
14
Types of OS:
Multiprogramming Systems
Multiprogramming Operating Systems can be simply illustrated as more
than one program is present in the main memory and any one of them can
be kept in execution.
This is basically used for better execution of resources (efficiency).
15
Types of OS:
Timesharing (Multitasking)
Each task is given some time to execute so that all the tasks work smoothly.
Each user gets the time of the CPU as they use a single system.
These systems are also known as Multitasking Systems.
Multitasking Operating System is simply a multiprogramming Operating
System with having facility of a Round-Robin Scheduling Algorithm.
The time that each task gets to execute is called quantum.
After this time interval is over OS switches over to the next task.
16
Types of OS:
Distributed Operating System
Various autonomous interconnected computers communicate with each
other using a shared communication network.
Independent systems possess their own memory unit and CPU.
These are referred to as loosely coupled systems or distributed systems.
These systems’ processors differ in size and function.
The major benefit of working with these types of the operating system is
that it is always possible that one user can access the files or software
which are not actually present on his system but some other system
connected within this network i.e., remote access is enabled within the
devices connected in that network.
17
Types of OS:
Network Operating System
These systems run on a server and provide the capability to manage data,
users, groups, security, applications, and other networking functions.
These types of operating systems allow shared access to files, printers,
security, applications, and other networking functions over a small private
network.
18
Types of OS:
Real-Time Operating System
The time interval required to process and respond to inputs is very small.
This time interval is called response time.
Real-time systems are used when there are time requirements that are
very strict like missile systems, air traffic control systems, robots, etc.
Types of Real-Time Operating Systems:
Hard Real-Time Systems: These OSs are meant for applications
where time constraints are very strict and even the shortest possible
delay is not acceptable. These systems are built for saving life like
automatic parachutes or airbags which are required to be readily
available in case of an accident.
Soft Real-Time Systems: These OSs are for applications where time-
constraint is less strict.
19
Operating System Services
An operating system provides an environment for the execution of
programs.
It provides certain services to programs and to the users of those
programs.
Figure 2.1 A view of operating system services.
20
…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).
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- 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
Error detection– OS needs to be aware of possible errors and debug
them.
21
…Operating-System Services
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, main memory, 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
22
System Calls
System calls provide the
interface between a process
and operating system .
System calls allow user-level
processes to request services of
the operating system.
Whenever a process needs to do
something that only the OS can do – it
performs a system call.
These calls are generally available as
routines written in C and C++.
A number associated with each system
call
System-call interface maintains a table
indexed according to these numbers
23
Types of System Calls
System calls can be grouped roughly into five major categories:
1.Process control
end, abort
load, execute
create process, terminate process
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
2.File management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
24
…Types of System Calls
3. Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
4. Information maintenance
get time or date, set time or date
get system data, set system data
get process, file, or device attributes
set process, file, or device attributes
5. Communications
create, delete communication connection
send, receive messages
transfer status information
attach or detach remote devices
25
Examples of Windows and Unix System Calls
26
System Programs
“The one program running at all times on the computer” is the kernel.
Everything else is either a system program, or an application program.
System programs(system utilities), provide a convenient environment for
program development and execution.
They can be divided into these categories:
1. File management (create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories).
2. Status information (Some ask the system for info - date, time, amount of
available memory, disk space, number of users. Others provide detailed
performance, logging)
3. File modification (Several text editors may be available to create and modify
the content of files stored on disk or other storage devices).
4. Program loading and execution (Once a program is assembled or compiled,
it must be loaded into memory to be executed).
5. Programming-language support (Compilers, assemblers, debuggers, and
Interpreters).
27
…System Programs
6. Communications (creating virtual connections among processes, users, and
computer systems. They allow users to send messages to one another’s screens,
to browse Web pages, to send e-mail messages, to log in remotely, or to transfer
files from one machine to another).
7. Background Services (running system-program processes are known as
services, subsystems, or daemons).
Along with system programs, most operating systems are supplied with programs
that are useful in solving common problems or performing common operations.
Such application programs.
8. Application programs (include Web browsers, word processors and text
formatters, spreadsheets, database systems, compilers, plotting and statistical-
analysis packages, and games).
28
Operating-System Structure
A system as large and complex as a modern operating system must be
engineered carefully if it is to function properly and be modified easily.
A common approach is to partition the task into small components, or
modules, rather than have one monolithic system.
Each of these modules should be a well-defined portion of the system, with
carefully defined inputs, outputs, and functions.
29
Operating-System Structure: Simple Structure
These systems started as small, simple, and limited systems and then grew
beyond their original scope.
MS-DOS is an example of such a system. It was written to provide the
most functionality in the least space, so it was not carefully divided into
modules.
Although MS-DOS has some
structure, its interfaces and
levels of functionality are not
well separated.
Figure 2.11 shows its
structure.
30
Operating-System Structure: Monolithic Structure
Like MS-DOS, UNIX initially was limited by hardware functionality.
It consists of two separable parts: the kernel and the system programs.
The kernel provides the file system, CPU scheduling, memory
management, and other operating-system functions through system calls.
31
Operating-System Structure: 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.
Advantages:
Modularity simplifies development and
debugging.
With modularity, layers are selected such
that each uses functions (operations) and
services of only lower-level layers.
Disadvantages:
The major difficulty with the layered approach
involves appropriately defining the various
layers, because a layer can use only lower-level
layers, careful planning is necessary.
32
Operating-System Structure: Microkernels
In the mid-1980s, researchers at Carnegie Mellon University developed an
operating system called Mach that modularized the kernel using the
microkernel approach.
Microkernel approach: minimal kernel, only essential components.
This method structures the operating system by removing all
nonessential components from the kernel and implementing them as
system and user-level programs → The result is a smaller kernel.
Advantages:
Easier to extend a microkernel (All new services are added to user
space and consequently do not require modification of the kernel)
provides more security and reliability(less code is running in kernel
mode since most services are running as user rather than kernel
processes. If a service fails, the rest of the operating system remains
untouched.)
Disadvantages:
Performance overhead of user space to kernel space communication.
33
…Operating-System Structure: Microkernels
The main function of the microkernel is to provide communication
between the client program and the various services that are also running
in user space.
Communication is provided through message passing, Figure 2.14
illustrates the architecture of a typical Microkernel.
34
Operating-System Structure: Modules
The best current methodology for operating-system design involves using loadable
kernel modules.
Here, the kernel has a set of core components and links in additional services via
modules, either at boot time or during run time.
Most modern operating systems implement kernel modules such as Solaris, Linux,
and Mac OS X, as well as Windows.
Advantages:
The overall result resembles a layered system in that each kernel section has
defined, protected interfaces; but it is more flexible than a layered system,
because any module can call any other module.
The approach is also similar to the microkernel approach in that the primary
module has only core functions and knowledge of how to load and communicate
with other modules; but it is more efficient, because modules do not need to
invoke message passing in order to communicate.
35
…Operating-System Structure: Modules
The Solaris operating system structure, shown in Figure 2.15, is organized around a
core kernel with seven types of loadable kernel modules.
Linux also uses loadable kernel modules, primarily for supporting device drivers and
file systems.
36
Operating-System Structure: Hybrid Systems
In practice, very few operating systems adopt a single, strictly defined
structure.
Instead, they combine different structures, resulting in hybrid systems that
address performance, security, and usability issues.
For example, both Linux and Solaris are monolithic, because having the
operating system in a single address space provides very efficient
performance.
However, they are also modular, so that new functionality can be
dynamically added to the kernel.
Examples: Apple Mac OS X operating system and the two most prominent
mobile operating systems, iOS and Android.
37
Example of hybrid systems:
Apple Mac OS X operating system
The Apple Mac OS X operating system uses a hybrid structure.
As shown in Figure 2.16, it is a layered system, the Kernel combines Mach microkernel
and the BSD UNIX layers, other services provided by modules.
The top layers include the Aqua user interface and a set of application environments and
services.
The Cocoa environment specifies an API for the Objective-C programming language, which is
used for writing Mac OS X applications.
Below these layers is the kernel environment, which consists primarily of the Mach
microkernel and the BSD UNIX kernel.
Mach provides memory management; support for remote procedure calls (RPCs) and
interprocess communication (IPC) facilities, including message passing; and thread scheduling.
The BSD component provides a BSD command-line interface, support for networking and file
systems, and an implementation of POSIX APIs, including Pthreads.
In addition to Mach and BSD, the kernel environment provides an I/O kit for development of
device drivers and dynamically loadable modules (which Mac OS X refers to as kernel
extensions).
As shown in Figure 2.16, the BSD application environment can make use of BSD facilities
directly.
38
39
THANK YOU!