0% found this document useful (0 votes)
32 views50 pages

Giu 2531 61 12754 2023-09-26T07 37 37

math

Uploaded by

Mohammed Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views50 pages

Giu 2531 61 12754 2023-09-26T07 37 37

math

Uploaded by

Mohammed Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

INCS102

OPERATING
SYSTEMS
DEFINITION

Dr. JOHN ZAKI 1


TABLE OF CONTENTS
01 WHAT IS OPERATING SYSTEM?

02 OS JOB

03 OS BASICS

04 OS SERVICES

05 OS STRUCTURES
Dr. JOHN ZAKI 2
LECTURE OBJECTIVES

Understand OS SERVICES
01
Describe SYSTEM CALLS, USER MODE, KERNEL MODE
02
Understand OS operations
03
Know different OS structure
04
Dr. JOHN ZAKI 3
What is an
operating
system
(OS)?
Dr. JOHN ZAKI 4
A program
User

Applications
that acts as an intermediary
between a user of a computer UTILITIES
and the computer hardware
Operating System

A KERNEL KERNEL

Is the only part of the OS that


CPU
runs all the time from the
HDD

start of the PC till the Hardware


shutdown. RAM I/O

Dr. JOHN ZAKI 5


2023: statistics - 27.8 million lines of code

Dr. JOHN ZAKI 6


What is the
job of an
(OS)?
Dr. JOHN ZAKI 7
USER VIEW

It is there for convenience,


ease of use, and good
SYSTEM VIEW
performance
Resource allocator, control
program that optimizes the
use of H/W. It optimizes for
efficiency and fairness

Dr. JOHN ZAKI 8


OS
BASICS

Dr. JOHN ZAKI 9


Computer System Organization
Computer-system operation
○ One or more CPUs, device controllers connect through common bus
providing access to shared memory
○ Concurrent execution of CPUs and devices competing for memory
cycles
Computer System Operation
● I/O devices and the CPU can execute concurrently
● Each device controller is in charge of a particular device
type
● Each device controller has a local buffer
● Each device controller type has an operating system
device driver to manage it
● CPU moves data from/to main memory to/from local
buffers
● I/O is from the device to local buffer of controller
● Device controller informs CPU that it has finished its
operation by causing an interrupt
Computer Startup

● 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


OS OPERATIONS
● Starts system daemons (services provided
outside of the kernel)

● Kernel interrupt driven (hardware and


software)
○ Hardware interrupt by one of the devices
(EX: I/O)

○ Software interrupt (exception or trap):


■ Software error (e.g., division by zero)
■ Request for operating system service
– system call
■ Other process problems include
infinite loop, processes modifying
each other or the operating system
INTERRUPT HANDLING
Common Functions of Interrupts

● Interrupt transfers control to the interrupt service routine generally,


through the interrupt vector, which contains the addresses of all the
service routines
● Interrupt architecture must save the address of the interrupted instruction
● A trap or exception is a software-generated interrupt caused either by an
error or a user request. It allows OS to take control.
EX: write a file to the HDD.
● An operating system (Kernel) is interrupt driven
Interrupt-drive I/O Cycle
OS
SERVICES

Dr. JOHN ZAKI 17


OS SERVICES

Dr. JOHN ZAKI 18


H/W ARCHITECTURE SUPPORT OS SERVICES
OS SERVICE HARDWARE SUPPORT

Protection Kernel / User Mode, protected


instructions, base/limit registers
Interrupts Interrupt Vectors

System Calls Trap

I/O Interrupts and Memory


Mapping
Scheduling & Error Recovery Timer

Synchronization Atomic Instructions

Dr. JOHN ZAKI 19


PROTECTION
EX:
Moving the content of an address to register ax
MOV [address], ax

Add registers ax, bx


ADD ax, bx

Software interrupt
INT n

Halt the PC
HLT

Load task register


LTR

Dr. JOHN ZAKI 20


DUAL MODE OPERATION
KERNEL MODE / USER MODE

Protect the system from users and


processors. Thus, some instructions are
restricted to use ONLY by the OS. In user
mode, the user is not allowed to …..

EX:
1. I/O instructions
2. Memory management instructions
3. Set the mode bit (user/kernel)
4. Disable or enable interrupt
5. Halt the machine

Dr. JOHN ZAKI 21


DUAL MODE OPERATION

Dr. JOHN ZAKI 22


DUAL MODE OPERATION
● Mode bit provided by hardware
○ Provides ability to distinguish when system is running user code or kernel
code.
○ When a user is running  mode bit is “user” =1
○ When kernel code is executing  mode bit is “kernel” = 0

● How do we guarantee that user does not explicitly set the mode bit to “kernel”?

○ System call changes mode to kernel, return from call resets it to user

● Some instructions designated as privileged, only executable in kernel mode


SYSTEM CALLS
● It is an OS procedure that an application calls to perform tasks on its
behalf.

● Programming interface to the services provided by the OS


● It is like the API of any software (but let’s call it the OS API)

● Three most common APIs:


○ Win32 API for Windows
○ POSIX API for POSIX-based systems (including virtually all versions
of UNIX, Linux, and Mac OS X)
○ Java API for the Java virtual machine (JVM)
SYSTEM CALL IMPLEMENTATION
● Typically, a number is associated with each system call
○ System-call interface maintains a table indexed according to these
numbers
● The system call interface invokes the 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 and


managed by run-time support library (set of functions built into
libraries included with compiler)
API – System Call – OS Relationship
Examples of Windows and Unix System Calls
MEMORY MANAGEMENT & PROTECTION
● To execute a program all (or part) of the instruction
and data must be in memory

● To protect the memory, OS doesn’t allow a program


to access another program’s memory location
through assigning base, and limit addresss.
BASE REG
● Memory management determines what is in memory
and when
○ Optimizing CPU utilization and computer
response to users
LIMIT REG

● Memory management activities


○ Keeping track of which parts of memory are
currently being used and by whom
○ Deciding which processes (or parts thereof)
and data to move into and out of memory
○ Allocating and deallocating memory space as
needed
MEMORY-STORAGE HIERARCHY
loading

evicting
How a Modern Computer Works

A von Neumann architecture


FILE SYSTEM MANAGEMENT

● OS provides uniform, logical view of information storage


○ Abstracts physical properties to logical storage unit - file
○ Files are organized into directors
○ Access control on who accesses what.

● OS File-System management activities

■ Creating and deleting files and directories


■ Primitives to manipulate files and directories
■ Mapping files onto secondary storage
■ Backup files onto stable (non-volatile) storage media
TIMER
Keep a counter that is decremented by
Prevent infinite loop or process the Timer physical clock. When counter
holding resources. Timer is set to zero generate an interrupt
interrupt the computer after some
time period.

Set up before scheduling process to


Supports synchronization and the
regain control or terminate program
use of Atomic instructions
that exceeds allotted time
I/O SUBSYSTEM

One purpose of OS is to hide peculiarities of


hardware devices from the user

Memory management of I/O include Buffering,


Caching, Spooling
VIRTUALIZATION

Allows operating systems to run applications within other OSes

Virtualization – OS natively compiled for CPU, running guest OSes also natively
compiled
a. Consider VMware running WinXP guests, each running applications, all on
native WinXP host OS
b. VMM (virtual machine Manager) provides virtualization services
VIRTUALIZATION EXAMPLES

Apple laptop running Mac OS X host, Windows as a guest

Developing apps for multiple OSes without having multiple systems

Quality assurance testing applications without having multiple systems

Executing and managing compute environments within data centers


Computing Environments - Virtualization
VMM can run natively, in which case they are also the host
OS
STRUCTURE
Dr. JOHN ZAKI 37
Simple structure (MS-DOS) Layered
Monolithic an abstraction

More complex (UNIX) Microkernel (Mach)


Monolithic – Original UNIX, MS-DOS

● limited by hardware functionality, the OS 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
Traditional UNIX System Structure
Linux System Structure

Monolithic plus modular design


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

● Each layer can talk to the layer above or


the layer below
Microkernels
● Moves as much from the kernel into user space

● Mach is an example of microkernel (Mac OS X partly based on it)


○ Mac OS X kernel (Darwin) partly based on Mach
● 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
● Downside:
○ Performance overhead of user space to kernel space
communication
Microkernel System Structure
Modules

● Many modern operating systems implement loadable kernel modules


(LKMs)
○ 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


○ Linux, Solaris, etc.
Hybrid Systems

Most modern operating systems are not one pure model

• Hybrid combines multiple approaches to address performance, security,


usability needs

Linux and Solaris kernels are monolithic in kernel address


space, plus modular for dynamic loading of functionality

Windows mostly monolithic, plus microkernel for different


subsystem personalities
Summarize other OS
services such as user
interface, program
execution, and error
detection

Dr. JOHN ZAKI 47


What are linkers, and
loaders?

Dr. JOHN ZAKI 48


SUMMARY

01 WHAT IS OS?

02 OS BASICS
(NEW, READY, RUNNING, WAITING, TERMINATED….ETC)

03 OS SERVICES
FORK, EXEC, WAIT, EXIT

04 OS ARCHITECTURE

Dr. JOHN ZAKI 49


THANK
YOU
Dr. JOHN ZAKI 50

You might also like