Lecture 03 AV-323 OS Operations and Resource Management

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

AV-323

Operating Systems
Lecture No 03
OS Operations and Resource
Management
Textbook: Operating Systems Concepts book by Silberschatz, Galvin,
and Gagne 10th Ed, 2018; Chapter 1

August 6, 2024
Number of Slides: 27
1
In the Last Lecture
• Computer System Organization
• I/O Structure
• Computer System Architecture
• Single-Processor Systems
• Multiprocessor Systems
• Clustered Systems

2
In This Lecture
• OS Operations
- Multiprogramming
- Dual Mode Operation
- Timer
• OS Resource Management
• Processes, files, memory, storage, cache, I/O
• Computing Environments
• Specifically real-time embedded systems

3
Operating-System
Operations
Section 1.4
- Bootstrap
- Multiprogramming
- Dual Mode Operation
- Timer
4
Operating-System Operations
• Bootstrap program – simple code to initialize the
system, and load the kernel
• Kernel loads
• Starts system daemons (computer program that
runs as a background process, rather than being
under the direct control of an interactive user)
• Kernel interrupt driven (hardware and software)
• Hardware interrupt by one of the devices
• Software interrupt (exception a.k.a. trap):
• Software error (e.g., division by zero)
• Request for operating system service – system call
5
Multiprogramming
• The ability to run multiple programs.
• Users typically want to run more than one program at
a time as well.
• Multiprogramming organizes jobs (code and data), so
CPU always has one to execute.
• A subset of total jobs in system is kept in memory.
• One job selected and run via job scheduling.
• When job has to wait (for I/O for example), OS
switches to another job.

6
Memory Layout for Multiprogrammed System

Processes waiting in queue

7
Dual-mode Operation
• Dual-mode operation allows OS to protect itself and
other system components
• User mode and kernel mode
• 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” (e.g., binary 1)
• When kernel code is executing  mode bit is “kernel”
(binary 0)
• Some instructions designated as privileged, only
executable in kernel mode
8
Transition from User to Kernel Mode

9
Timer
• We must ensure that the operating system maintains
control over the CPU.
• A user program may stick in an infinite loop.
• Timer is used to prevent such infinite loop
• Timer is set to interrupt the computer after some time
period (e.g., 1/60 seconds).
• Operating system set the counter (privileged instruction).
• When counter reaches zero, an interrupt is generated.

10
OS Resource
Management
Section 1.5
- Process management
- Memory management
- File-system management
- Mass-storage management
- Cache management
- I/O management
- Protection and security
- Virtualization 11
Process Management
• A process is a program in execution. It is a unit of work within the
system. Program is a passive entity; process is an active entity.
• Process execution needs resources to accomplish its task
• CPU, memory, I/O, files, storage
• Process termination requires reclaim of any reusable resources
• Single-threaded process has one program counter specifying
location of next instruction to execute
• Process executes instructions sequentially, one at a time, until
completion
• Multi-threaded process has one program counter per thread
• Concurrency by multiplexing the CPUs among the
processes / threads 12
Process Management Activities
• Creating and deleting both user and system
processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
• Providing mechanisms for deadlock handling

13
Memory Management
• To execute a program, all (or part) of the instructions
must be in memory
• All (or part) of the data that is needed by the program
must be in memory
• Memory management determines what is in the
memory and when?
• For optimizing CPU utilization and computer response to
users

14
File-system Management
• OS provides uniform, logical view of information storage
• Abstracts physical properties to logical storage unit called file
• Each medium is controlled by device (i.e., disk drive, tape drive)
• Varying properties include access speed, capacity, data-transfer rate,
access method (sequential or random)

• File-System management
• Files usually organized into directories
• Access control on most systems to determine who can access
what
• OS activities include
• 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 15
Mass-Storage Management
• Usually, disks used to store data that does not fit in main
memory or data that must be kept for a “long” period of time
• Proper management is of central importance
• Entire speed of computer operation hinges on disk
subsystem and its algorithms
• OS activities
• Mounting and unmounting
• Free-space management
• Storage allocation
• Disk scheduling (for efficient I/O access schedules)
• Partitioning
• Protection
16
Caching
• Important principle, performed at many levels in a
computer (in hardware, operating system, software)
• Information in use copied from slower to faster
storage temporarily
• Faster storage (cache) checked first to determine if
information is there
• If it is, information used directly from the cache (fast)
• If not, data copied to cache and used there

17
Characteristics of Various Types of Storage

programmer

Movement between levels of storage hierarchy can be


explicit or implicit 18
Migration of Data “A” from Disk to Register
• Multitasking environments must be careful to use most
recent value, no matter where it is stored in the storage
hierarchy.

• Multiprocessor environment must provide cache


coherency in hardware such that all CPUs have the
most recent value in their cache.
• Distributed environment situation even more complex
• Several copies of a datum can exist
19
I/O Subsystem
• One purpose of OS is to hide peculiarities of
hardware devices from the user
• I/O subsystem responsible for
• Memory management of I/O including buffering (storing
data temporarily while it is being transferred), caching
(storing parts of data in faster storage for performance),
spooling (the overlapping of output of one job with input of
other jobs)
• General device-driver interface
• Drivers for specific hardware devices

20
Protection and Security
• Protection – any mechanism for controlling access of
processes or users to resources defined by the OS
• Security – defense of the system against internal and
external attacks
• Huge range, including denial-of-service, worms, viruses,
identity theft

21
Virtualization
• Allows operating systems to run applications within
other OSes.
• Allows us to abstract the hardware of a single
computer into several different execution
environments, thereby creating the illusion that each
separate environment is running on its own private
computer.
• For example, run Linux on Windows 10 using a
commercial software called VMWare.

22
Virtualization

e.g., VMWare

23
Computing
Environments

24
Computing Environments
• Traditional (e.g., your laptop)
• Mobile (e.g., your smartphone)
• Client Server (e.g., many PCs connected to a single
printer)
• Peer-to-Peer (e.g., Skype (VoIP))
• Cloud computing (e.g., OneDrive)
• Real-time Embedded (e.g., air traffic control system)
• Free and Open-Source OSes (e.g., Linux)

25
Real-time Embedded Systems
• Embedded computers are the most prevalent form of
computers in existence.
• found everywhere, from car engines and manufacturing
robots to optical drives and microwave ovens.
• OS for real-time applications are called Real Time
Operating Systems (RTOS)
• RTOS is intended to serve real-time applications that
process data as it comes in, typically without buffer
delays.
• A real-time system is a time-bound system, which has
well-defined, fixed time constraints.
26
Summary
• OS Operations
- Multiprogramming
- Dual Mode Operation
- Timer
• OS Resource Management
• Processes, files, memory, storage, cache, I/O
• Computing Environments
• Specifically real-time embedded systems

27

You might also like