0% found this document useful (0 votes)
19 views71 pages

Lecture 2-Operating Systems

The document outlines the course CSE 421/521 on Operating Systems, covering topics such as computer architecture, the definition and functions of an operating system, major components, design approaches, and the Pintos operating system framework. It emphasizes the roles of the OS in managing hardware resources, providing user convenience, and ensuring efficient operation. The document also discusses various OS design methodologies including layered, microkernel, and modular approaches.

Uploaded by

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

Lecture 2-Operating Systems

The document outlines the course CSE 421/521 on Operating Systems, covering topics such as computer architecture, the definition and functions of an operating system, major components, design approaches, and the Pintos operating system framework. It emphasizes the roles of the OS in managing hardware resources, providing user convenience, and ensuring efficient operation. The document also discusses various OS design methodologies including layered, microkernel, and modular approaches.

Uploaded by

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

CSE 421/521

Introduction to Operating Systems


Farshad Ghanei
Mostafa Mohammed

Operating Systems

* Slides adopted from Prof Kosar, Dantu, and Farshad Ghanei at UB, “Operating System
Concepts” book and supplementary material by A. Silberschatz, P.B. Galvin, and G. Gagne.
Wiley Publishers

The materials provided by the instructor in this course are for the use of the students enrolled in the course only.
Copyrighted course materials may not be further disseminated without instructor permission.
Summary
● Course logistics

2
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

3
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

4
Computer Architecture
● Everything down at HW level is hardwired
○ How does it do it?
○ Where does the complication form?
○ How does it know?

5
Computer Architecture
● Everything down at HW level is hardwired
○ How does it do it?
○ Where does the complication form?
○ How does it know?

● Biology is a good example!

6
Von Neumann Architecture

➢ From https://en.wikipedia.org/wiki/Von_Neumann_architecture
7
Intel 8085

➢ From https://slideplayer.com/slide/2817140/
8
Some of 8085 Important Components
● Program Counter
● Instruction Register and Decoder
● ALU
● Flag Register
● Registers
● Stack Pointer
● Interrupt Controller
○ Timer (Hint!)
○ Communication
○ TRAP
○ 9
Software Interrupt
Execution Steps Simplified
● Fetch instruction at PC
● Decode the instruction
● Execute (possibly using registers and modifying them)
● Write possible result to registers/memory
● Increase PC to point to the next instruction

REPEAT!

10
Execution Steps

➢ From https://www.vectorstock.com/royalty-free-vector/manufacture-interior-with-vector-23241154
11
Instruction Set

➢ From https://stackoverflow.com/questions/6924912/finding-number-of-operands-in-an-instruction-from-opcodes
12
Modern Computer Architecture

13
Limitations
● Only a single user at a time
○ Who manages?
● Each user will need to be independent, and have full stack software
○ Drivers, all of them!
○ Compilers
○ I/O
○ etc.
● Each user have full access!
○ Protection and Security

14
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

15
What is an Operating System?
● It is a program!
○ A big one
● OS manages the computer hardware resources
○ Manages all resources
○ Decides between conflicting requests for efficient and fair resource use
● OS is a control program
○ Controls execution of programs to prevent errors and improper use of the
computer
● Acts as an intermediary between a user of a computer and the computer hardware

16
What is an Operating System?

17
Operating System Goals
From the user perspective:
● Executes user programs and make solving user problems easier
● Makes the computer system convenient to use
● Hides the messy details which must be performed
● Presents user with a virtual machine easier to use

From the system/HW perspective:


● Manages the resources
● Uses the computer hardware in an efficient manner
● Time sharing: each program gets some time to use a resource
● 18
Resource sharing: each program gets a portion of a resource
What is kernel?
● No universally accepted definition
● Everything a vendor ships when you order an operating system is a good
approximation (But varies wildly!)
● “The one program running at all times on the computer” is the kernel. Everything else
is either a system program (ships with the operating system), or an application
program.

19
Early Operating Systems: Serial Operations
● One application at a time
○ Had complete control of hardware
○ OS was runtime library
○ Users would stand in line to use the computer
● Batch systems
○ Keep CPU busy by having queue of jobs
○ OS would load next job while current one runs
○ Users would submit jobs, and wait, and wait...

20
Time-Sharing Operating Systems
● Multiple users on computer at same time
● Interactive performance: try to complete everyone’s tasks quickly
● As computers became cheaper, it became more important to optimize for user time,
not computer time.
● Programs that they do not finish.

21
Computer Performance Over

22
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

23
Major OS Components
● Processes and Threads
● CPU Scheduling
● I/O Management
● Memory Management

24
Processes and Threads
● A process is a program in execution.

25
Processes and Threads
● It can be interrupted to let the CPU execute a higher-priority process.

26
Processes and Threads
● … and then resume exactly where the CPU left off.

27
Processes and Threads: Multitasking/Time-
sharing
● Multitasking gives the illusion of parallel processing on one CPU.
● Time-sharing is a logical extension in which CPU switches jobs so frequently that
users can interact with each job while it is running, creating interactive computing.

28
Processes and Threads: OS Responsibilities
● The OS creates and deletes processes and threads.
● The OS suspends and resumes processes and threads.
● The OS schedules processes and threads.
● The OS provides mechanisms for process synchronization.
● The OS provides mechanisms for interprocess communication.
● The OS provides mechanisms for deadlock handling.

29
CPU Scheduling
A process changes its state during execution:
● New: The process is being created
● Ready: The process is waiting to be assigned to a processor
● Running: Instructions are being executed
● Waiting: The process is waiting for some event to occur
● Terminated: The process has finished execution

30
CPU Scheduling: OS Responsibilities
● The OS decides which available processes in memory are to be executed by the
processor.
● The OS decides what process is executed when and for how long.
● The OS handles external events such as I/O interrupts, possibly changing the
schedule flow.
● OS relies on a scheduling algorithm that attempts to optimize CPU utilization,
throughput, latency, and/or response time, depending on the system requirements.

31
I/O Management
● Layers of the I/O subsystem

32
I/O Management
● I/O Device Queues

33
I/O Management: Two Methods
Synchronous Asynchronous
● Control returns to the user program ● Control returns to user program without
only upon I/O completion waiting for I/O completion
● Wait loop until next interrupt ● Operating system communicates the
● At most one I/O request is outstanding completion of request through a signal,
at a time, no simultaneous I/O call-back, etc.
processing for the process ● Process can run while the I/O gets
finished

34
I/O Management: Two Methods

35
I/O Management: Interrupt Handling
● Interrupts, interrupt the execution flow!

36
I/O Management: Interrupt Handling

37
I/O Management: OS Responsibilities
● The OS hides the peculiarities of specific hardware devices from the user.
● The OS issues the low-level commands to the devices, catches interrupts and
handles errors.
● The OS relies on software modules called “device drivers”.
● The OS provides a device-independent API to the user programs, which includes
buffering.

38
Memory Management
● Memory needs to be subdivided to accommodate multiple processes
● Memory management is an optimization task under constraints
● Movement between levels of storage hierarchy:

39
Memory Management: OS Responsibilities
● The OS keeps track of which parts of memory are currently being used and by whom.
● The OS allocates and deallocates memory space as needed.
● The OS decides which processes to load or swap out.
● The OS ensures process isolation.
● The OS regulates how different processes and users can sometimes share the same
portions of memory.
● The OS transfers data between main memory and disk and ensures long-term
storage.

40
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

41
OS Design Approaches
● Start defining goals and specifications
● Affected by choice of hardware, type of system
○ Batch, time-shared, single user, multi user, distributed
● Goal perspective:
○ User goals: operating system should be convenient to use, easy to learn,
reliable, safe, and fast.
○ System goals: operating system should be easy to design, implement, and
maintain, as well as flexible, reliable, error-free, and efficient.

● No unique solution! A variety of operating systems!


42
OS Design Approaches: Policy vs Mechanism
It is an important principle to separate policies and mechanisms:
● Policy: What should be done?
● Mechanism: How will it get done?

Example: to ensure CPU protection:


● Policy: each process gets a limited execution time.
● Mechanism: Use Timer construct

This separation allows flexibility if policy decisions are to be changed later.

43
OS Design Approaches
● Simple Structure
● Layered
● Microkernels
● Modular
● Hybrid Systems

44
OS Design Approaches: Simple Structure
● No well defined structure
● Start as small, simple, limited systems, and then grow
● No well defined layers, not divided into modules
● Example: MS-DOS
○ Initially written to provide the most
functionality in the least space
○ Grew beyond its original scope
○ Levels not well separated:
Programs access I/O directly
○ Excuse? The hardware of that time
45
was limited (no user/kernel mode)
OS Design Approaches: Layered
Monolithic Operating Systems:
● No one had experience in building truly large software systems
● The problems caused by mutual dependence and interaction were grossly
underestimated
● Such lack of structure became unsustainable as OS grew
● Early UNIX, Linux, Windows systems were monolithic, partially layered

Enter hierarchical layers and information abstraction


● Each layer is implemented exclusively using operations provided by the lower layers
● It does not need to know how they are implemented
● 46
Lower layers abstract certain data structures and operations
Simple Layered Approach
● Enormous amount of functionality The original UNIX
crammed into the kernel
● “The Big Mess”: a collection of
procedures that can call any of
the other procedures whenever
they need to
● No encapsulation, total visibility
across the system
● Very minimal layering

47
Fully Layered Approach
● The OS is divided into a number of
layers, each built on top of lower layers.
● With modularity, layers are selected
such that each uses functions and
services of only lower layers
● THE system (by Dijkstra), MULTICS,
GLUnix, VAX/VMS

48
Layered Approach
Layers can be debugged and replaced independently without bothering the other layers
above or below.
Famous example: TCP/IP networking stack

49
Layered Approach

50
Layered Approach
Major difficulty with layering:
● Appropriately defining the various layers!
● The more layers, the more indirections from function to function and the bigger the
overhead in function calls
● Layering is only possible if all function dependencies can be sorted out in a Directed
Acyclic Graph (DAG)
● However there might be conflicts in the form of circular dependencies (cycles)

51
OS Design Approaches: Microkernels
● A microkernel is a reduced operating system core that contains only essential OS
functions.
● The idea is to minimize the kernel by moving up as much functionality as possible
from the kernel into user space.
● Many services traditionally included in the OS are now external subsystems running
as user processes:
○ Device drivers
○ File systems
○ Virtual memory manager
○ Windowing GUI system
○ 52
Security services
Microkernel Approach
Examples: QNX, Tru64 UNIX, Mach (CMU), Windows NT

53
Layered OS vs Microkernel

54
Microkernel Approach
● Pros:
○ Extensibility: It is easier to extend a microkernel-based OS as new services are
added in user space, not in the kernel.
○ Portability: It is easier to port to a new CPU, as changes are needed only in the
microkernel, not in the other services
○ Reliability & security: Much less code is running in kernel mode. Failures in
user space services don’t affect kernel space.
● Cons:
○ Again, performance overhead due to communication from user space to kernel
space
○ 55
Not always realistic, some functions must remain in kernel space.
OS Design Approaches: Modular
● Many modern operating systems implement kernel modules.
○ Modern UNIX, Solaris, Linux, Windows, Mac OS X
● This is similar to object-oriented approach:
○ Each module talks to the others over known interfaces.
○ Each module is loadable dynamically as needed within the kernel.
● Overall, modules are similar to layers, but with more flexibility.
○ All are within kernel and any module could call any other module.
● Modules are also similar to the microkernels, except that they are inside the kernel
and don’t need message passing.

56
Modular Approach
● Modules are used in Solaris, Linux and Mac OS X

57
OS Design Approaches: Hybrid Systems
● Many real OSs use a combination of different approaches
○ Linux: Monolithic & modular
○ Windows: Monolithic & microkernel & modular
○ Mac OS X: Microkernel & modular

58
Today
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
● OS design approaches
● Pintos

59
Pintos
Your programming assignments are based on Pintos operating system:
● A Simple operating system framework for the 80x86 architecture.
● Developed by Stanford University (Originally by Ben Pfaff)
● Could theoretically run on a regular IBM-compatible PC
● Practically, it runs using Bochs and QEMU simulators
(OS in OS ?)
● Each and every student might have a different environment, which affects
development, and running
● We provide a Docker Image with Ubuntu (Similar to a Virtual Machine)
○ Download Docker and the image, and follow the instructions
● We’ll run Bochs and QEMU within the Docker container (OS in OS in OS ?)
60
Pintos Projects
● Threads (PA1)
● User Programs (PA2)
● Virtual Memory
● File Systems

61
Pintos (1/8) - Pre Project 1

62
Pintos (2/8) - Post Project 1

63
Pintos (3/8) - Pre Project 2

64
Pintos (4/8) - Post Project 2

65
Pintos (5/8) - Pre Project 3

66
Pintos (6/8) - Post Project 3

67
Pintos (7/8) - Pre Project 4

68
Pintos (8/8) - Post Project 4

69
Summary
● A very brief history of computer architecture
● What is an OS? What does an OS do?
● Major OS components
- Processes and Threads
- CPU Scheduling
- I/O Management
- Memory Management
● OS design approaches
● Pintos

70
Acknowledgements
● “Operating Systems Concepts” book and supplementary material by A. Silberschatz,
P. Galvin and G. Gagne
● “Operating Systems: Internals and Design Principles” book and supplementary
material by W. Stallings
● “Modern Operating Systems” book and supplementary material by A. Tanenbaum
● R. Doursat and M. Yuksel from University of Nevada, Reno
● T. Kosar and K. Dantu from University at Buffalo

71

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy