Download CSI 1002 Module1 Introduction

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSI1002- Operating System Principles
Reference Textbook: Operating System Concepts by Avi Silberschatz, Greg Gagne, and Peter Baer Galvin
Fall-Semester2021-2022
SCOPE
1
CSI1002- Operating System Principles
Syllabus
Module 1: Introduction - 4 hours
Computer-System Organization, Computer-System Architecture, Operating-System
Structure (monolithic, layered, modular, micro-kernel models), Operating-System
Operations, Operating-System Services, User and Operating- System Interface, System
Calls.
Module 2: Processes - 4 hours
Process Concept, Operations on Processes, Inter-process Communication, Threads Overview, Multithreading Models.
Module 3: CPU Scheduling - 4 hours
Basic Concepts, Scheduling Criteria, Scheduling Algorithms, Threads, MultipleProcessor Scheduling, Deadlocks- System Model, Deadlock Characterization, Methods
for Handling Deadlocks, Deadlock Prevention, Deadlock Avoidance, Deadlock
Detection, Recovery from Deadlock.
Module 4: Process Synchronization - 4 hours
Background, The Critical-Section Problem, Peterson’s Solution, Synchronization
Hardware, Mutex Locks, Semaphores, Classic Problems of Synchronization, Monitors,
Synchronization Example
SCOPE
2
CSI1002- Operating System Principles
Syllabus
Module 5: Memory Management- 4 hours
Memory Management 4 hours CO:5 Introduction, Swapping, Contiguous Memory
Allocation, Segmentation, Paging, structure of the Page Table.
Module 6: Virtual Memory - 4 hours
Background, Demand Paging, Page Replacement, Allocation of Frames, Thrashing,
Introduction to Virtualization.
Module 7: Mass-Storage Structure 4 hours
Overview, Disk Structure, Disk Scheduling. File -System Interface - File Concept, Access
Methods, Directory and Disk Structure, Directory Implementation, Allocation Methods.
Future directions in Mobile OS.
Module 8: Recent Trends -2 hours
SCOPE
3
CSI1002- Operating System Principles
Course Assessments - Rubrics
Assessment includes
• Two Continuous assessment tests
• 1 Digital assignment
• 2 Quizzes
• Lab sessions
• Final assessment test
SCOPE
4
CSI1002- Operating System Principles
Introduction
SCOPE
5
CSI1002- Operating System Principles
Computer Systems
Hardware
CPU
Memory
I/O
?
Programs
User
Task 1
User 1
Task 2
User 2
…
…
Task N
User N
SCOPE
CSI1002- Operating System Principles
Computer Systems
Hardware
Programs
User
CPU
Task 1
User 1
Task 2
User 2
…
…
Task N
User N
Memory
I/O
Operating
System
SCOPE
CSI1002- Operating System Principles
Four Components of a Computer System
SCOPE
CSI1002- Operating System Principles
What is an Operating System?
• An Operating System is a program that controls the execution of
application programs and acts as an intermediary/interface between a
user of a computer and the computer hardware
• An operating system is a program that manages the computer
hardware.
• An Operating System is a set of system software programs in a
computer that regulates:
The ways application software program use the computer hardware
&
The ways that Users control the computer
SCOPE
CSI1002- Operating System Principles
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
SCOPE
CSI1002- Operating System Principles
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
SCOPE
CSI1002- Operating System Principles
Storage Structure
Main memory – only large storage media that the CPU can access
directly
• Random access
• Typically volatile
Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
Magnetic disks – rigid metal or glass platters covered with magnetic
recording material
• Disk surface is logically divided into tracks, which are
subdivided into sectors
• The disk controller determines the logical interaction between
the device and the computer
SCOPE
CSI1002- Operating System Principles
Storage Device Hierarchy
Storage systems organized in
hierarchy
– Speed
– Cost
– Volatility
SCOPE
CSI1002- Operating System Principles
Storage Device Hierarchy
SCOPE
CSI1002- Operating System Principles
Computing System Architecture
Most systems use a single general-purpose processor
• Most systems have special-purpose processors as well
Multiprocessors systems growing in use and importance
• Also known as parallel systems, tightly-coupled systems
• Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault tolerance
• Two types:
1. Asymmetric Multiprocessing – each processor is assigned a
specie task.
2. Symmetric Multiprocessing – each processor performs all
tasks
SCOPE
CSI1002- Operating System Principles
Symmetric Multiprocessing Architecture
SCOPE
CSI1002- Operating System Principles
A Dual Core Design
• Multi-chip and multicore
• Systems containing all chips
– Chassis containing multiple separate systems
SCOPE
CSI1002- Operating System Principles
Clustered Systems
• Like multiprocessor systems, but multiple systems working
together
– 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
– Some clusters are for high-performance computing (HPC)
• Applications must be written to use parallelization
– Some have distributed lock manager (DLM) to avoid
conflicting operations
SCOPE
CSI1002- Operating System Principles
Clustered Systems
SCOPE
CSI1002- Operating System Principles
Operating System Services
Operating System Principles provide an environment for
execution of programs and services to programs and users
One set of operating-system services provides functions that are
helpful to the user:
• User interface - Almost all Operating System Principles
have a user interface (UI).
– Varies between Command-Line (CLI), Graphics User
Interface (GUI), Batch
• 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
SCOPE
CSI1002- Operating System Principles
Operating System Services
Operating System Principles provide an environment for
execution of programs and services to programs and users
One set of operating-system services provides functions that are
helpful to the user:
• User interface - Almost all Operating System Principles
have a user interface (UI).
– Varies between Command-Line (CLI), Graphics User
Interface (GUI), Batch
• 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
SCOPE
CSI1002- Operating System Principles
Operating System Services (Cont.)
One set of operating-system services provides functions that are
helpful to the user (Cont):
• 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 – OS needs to be constantly aware of
possible errors
– May occur in the CPU and memory hardware, in I/O
devices, in user program
– For each type of error, OS should take the appropriate
action to ensure correct and consistent computing
– Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
SCOPE
CSI1002- Operating System Principles
Operating System Services (Cont.)
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
SCOPE
CSI1002- Operating System Principles
Operating System Services (Cont.)
Another set of OS functions exists for ensuring the efficient
operation of the system itself via resource sharing:
• 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
– If a system is to be protected and secure, precautions
must be instituted throughout it. A chain is only as strong
as its weakest link.
SCOPE
CSI1002- Operating System Principles
Design Issues
Design Goals and Specification
Highest Level
– Choice of Hardware
– Type of System
• Batch / Time Shared
• Single User / Multi User
• Distributed / Real-time / General Purpose
Requirement Level
– User Goals
– System Goals
Mechanism and Policies
– Policy: What will be done?
– Mechanism: How to do it?
Implementation Issues
Selection of Language
SCOPE
CSI1002- Operating System Principles
Operating System Structures
Why??
Types
• Simple structure - MS-DOS
– Complex - UNIX
• Layered - An abstraction
• Microkernel – Mach
• Modular - Solaris
SCOPE
CSI1002- Operating System Principles
Simple Structure -- MS-DOS
• MS-DOS – written to provide
the most functionality in the
least space
– Not divided into modules
– Although MS-DOS has
some structure, its
interfaces and levels of
functionality are not well
separated
SCOPE
CSI1002- Operating System Principles
Complex Structure -- UNIX
UNIX – limited by hardware functionality, the original UNIX
operating system 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
SCOPE
CSI1002- Operating System Principles
Traditional UNIX System Structure
Beyond simple but not fully layered
SCOPE
CSI1002- Operating System Principles
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
SCOPE
CSI1002- Operating System Principles
Microkernel System Structure
• Moves as much from the kernel into user space
• Mach example of microkernel
– 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
• Detriments:
– Performance overhead of user space to kernel space
communication
SCOPE
CSI1002- Operating System Principles
Microkernel System Structure
Application
Program
File
System
messages
Interprocess
Communication
Device
Driver
user
mode
messages
memory
managment
CPU
scheduling
kernel
mode
microkernel
hardware
SCOPE
CSI1002- Operating System Principles
Modules
• Many modern Operating System Principles implement loadable
kernel modules
– 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
SCOPE
CSI1002- Operating System Principles
Solaris Modular Approach
SCOPE
CSI1002- Operating System Principles
User Mode and Kernel Mode
Dual-mode operation allows OS to protect itself and other system
components
o User mode and kernel mode
o Mode bit provided by hardware
• Provides ability to distinguish when system is running user
code or kernel code
• Some instructions designated as privileged, only executable
in kernel mode
• System call changes mode to kernel, return from call resets it
to user
Increasingly CPUs support multi-mode operations
i.e. virtual machine manager (VMM) mode for guest VMs
SCOPE
CSI1002- Operating System Principles
Transition from User to Kernel Mode
Timer to prevent infinite loop / process hogging resources
• Timer is set to interrupt the computer after some time period
• Keep a counter that is decremented by the physical clock.
• Operating system set the counter (privileged instruction)
• When counter zero generate an interrupt
• Set up before scheduling process to regain control or terminate
program that exceeds allotted time
SCOPE
CSI1002- Operating System Principles
System Calls
• Programming interface to the services provided by the OS
• Typically written in a high-level language (C or C++)
• Mostly accessed by programs via a high-level Application
Programming Interface (API) rather than direct system call use
• Three most common APIs are Win32 API for Windows, POSIX API
for POSIX-based systems (including virtually all versions of UNIX,
Linux, and Mac OS X), and Java API for the Java virtual machine
(JVM)
SCOPE
CSI1002- Operating System Principles
Examples of System Calls
System call sequence to copy the contents of one file to another file
SCOPE
CSI1002- Operating System Principles
System Calls Implementation
Typically, a number 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
o Managed by run-time support library (set of functions built
into libraries included with compiler)
SCOPE
CSI1002- Operating System Principles
API – System Call relationship
SCOPE
CSI1002- Operating System Principles
System Calls Parameter Passing
Often, more information is required than simply identity of desired
system call
Exact type and amount of information vary according to OS and call
Three general methods used to pass parameters to the OS
• Simplest: pass the parameters in registers
o In some cases, may be more parameters than registers
• Parameters stored in a block, or table, in memory, and address of
block passed as a parameter in a register
o This approach taken by Linux and Solaris
• Parameters 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
SCOPE
CSI1002- Operating System Principles
Parameter Passing via table
SCOPE
CSI1002- Operating System Principles
Types of System Calls
Process control
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
SCOPE
CSI1002- Operating System Principles
Types of System Calls
File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
SCOPE
CSI1002- Operating System Principles
Types of System Calls
Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
Communications
• create, delete communication connection
• send, receive messages if message passing model to host name
or process name
o From client to server
• Shared-memory model create and gain access to memory
regions
• transfer status information
• attach and detach remote devices
SCOPE
CSI1002- Operating System
Principles
Types of System Calls
Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
SCOPE
CSI1002- Operating System Principles
Summary
Operating System Definition
Computer System Organization
Storage Structure
Storage Device Hierarchy
Operating System Services
Design Issues
Operating System Structure
System Calls
SCOPE