Computing Systems W8 part 2 Flashcards
Program vs process
program (passive) & process (active)
process:
instance of a program
requires resources (CPU, memory, IO, data)
program counter for execution
process resources (5)
CPU, memory, I/O , files, data
reusable resources are reclaimed when process terminates
single-threaded process manager
one program counter : executes one instruction at a time
multi-threaded process manager
multiple program counters for parallel execution
Parallel execution
simultaneous execution of multiple processes or threads, typically on multiple CPU cores or processors.
concurrent execution
operating system switches between processes, giving the illusion of simultaneous execution.
Process management activities (4)
Creating/Deleting user & system processes
Stopping/Starting processes
process synchronization & communication
Deadlock handling
process synchronization (3)
control multiple processes (threads) to preserves system integrity and avoids undesirable outcomes
Ensures only one process can access a shared resource at a time
Facilitates interaction between processes
Controls the order of execution
deadlock
two or more processes are unable to proceed because each is waiting for the other to release a resource, resulting in a cyclic waiting scenario.
Memory Management (3)
Keep track of currently used memory
Decides which process and data move in/out of memory
allocates/deallocate memory space as need
Program execution and Memory
Memory must contain ALL program instructions in order to execute the program
data required by the program must be in memory
Memory management advantages
improve CPU utilization and computer response speed
file
Standardized model that represents a collection of related information.
Users work with files and OS translates file operations into operations on storage devices
ex. files represent programs and data
Storage management (4)
OS provides users with file system to view information. Users interact with files (logical storage units)
create/delete files & directories
support for manipulating files/directories
Mapping files to mass storage
Backing up files on nonvolatile storage
Storage device properties (4)
speed (fast access to data)
capacity (big or small)
data-transfer rate (efficiency)
access method (how data is accessed, in order or random)
Mass Storage Management (3)
Computer speed and efficiency depends on mass storage system and management algorithms
Free-space management
Storage allocation
Disk scheduling
Mass Storage
Used for data that is meant to be kept for long periods. Used frequently so it must be efficient
ex.
secondary: HDD, SSD
tertiary: optical storage, magnetic tape (not as efficient)
I/O subsystem components (3)
Memory management of I/O
- buffer (storage)
- caching
- spooling (I/O data is first spooled into a local buffer before sending data to output device)
- device driver interface
- Drivers for specific hardware
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
UserID
When user logs in to the system, the authentication determines user ID for the user. That user ID is associated with all of the user’s processes and threads.
GroupID
ID to distinguish among sets of users
escalate privileges
allows user to change to effective ID with more rights
Cloud computing
delivers computing, storage, and applications as a service across a network (extension of virtualization)
Virtualization
Multiple simulated (virtual) versions of something on a single physical system
ex. Virtual Machine is like a computer within a computer. Multiple virtual machines on one physical machine, each with its own OS and applications
Software as a service (SaaS)
one or more applications available via the internet
Platform as a service
software stack ready for application use via internet (i.e. database server)
Infrastructure as a Service (IaaS)
servers or storage available over internet (i.e. storage available for backup use)
load balancers
spread traffic across multiple applications
Real-time embedded systems
systems integrated into other devices that focus on real-time processing. Designed to perform specific tasks with a focus on meeting strict time constraints
constraints
- processes must be executed within specific time limits
i.e. sound system of computer
command interpreter
Also known as CLI (when there are multiple it is called shell)
provides direct command entry (can be implemented by kernel or system program)
(UNIX) fetches command from user and CLI identify file to be loaded into memory and execute command
ex bash, C shell, Korn shell
User OS Interface GUI
Graphical User Interface
rather than entering commands
directly via a command-line interface, users employ a mouse-based window-and-menu system characterized by a desktop metaphor
ex. mouse, keyboard, monitor
System call
Allows user programs to request services from OS
provide an interface to the system calls available by OS. Access by programs via API (Win32, POSIX, Java API)
These calls are generally available as functions written in C and
C++, although certain low-level tasks
System-call interface
Intercepts function calls in API and invokes system call
System call table indexed according to system call number
invokes a system call in OS kernel and return status of system call + return values
System call types (6)
Process control
file management
device management
information maintenance
communications
protection
Process control system call (5)
◦ create process, terminate process
◦ load, execute
◦ get process attributes, set process attributes
◦ wait event, signal event
◦ allocate and free memory
ex.
CreateProcess() fork()
ExitProcess() exit()
WaitForSingleObject()
file management system call (4)
◦ create file, delete file
◦ open, close
◦ read, write, reposition
◦ get file attributes, set file attributes
ex.
CreateFile()
ReadFile()
WriteFile()
CloseHandle()
device management system call (4)
request device, release device
◦ read, write, reposition
◦ get device attributes, set device attributes
◦ logically attach or detach devices
ex.
SetConsoleMode() ioctl()
ReadConsole() read()
WriteConsole()
information maintenance system call (4)
◦ 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
ex.
GetCurrentProcessID() getpid()
SetTimer() alarm()
Sleep()
communications system call (4)
◦ create, delete communication connection
◦ send, receive messages
◦ transfer status information
◦ attach or detach remote devices
ex.
CreatePipe() pipe()
CreateFileMapping() shm open()
MapViewOfFile()
protection system call (2)
◦ get file permissions
◦ set file permissions
ex.
SetFileSecurity() chmod()
InitlializeSecurityDescriptor() umask()
SetSecurityDescriptorGroup()
System programs
provide an environment for program development and execution. Provides essential services without direct user interaction
ex. user interface to system calls
file management: create, delete, copy, remain
System call process
- User program initiates system call
- Mode switches to kernel mode
- Control is transferred to specific system call function
- Validation takes place to ensure user program has permissions to perform request
- System call executes
- After completing, handler returns results to user program
- Control returns to user mode and it continue execution
System programs characteristic
Some launched during system boot up
Some run continuously from boot to shutdown
Run in user mode ( do not have privileged permission)
referred to as services/subsystems/daemons
Application programs
user-oriented programs that do not pertain to core functioning of OS
Users initiate and run application programs
Considered external software that performs specific task
How to design an OS
- define goals and specifications
- Choose hardware
user goals
operating system should be convenient to use, easy to learn, reliable, safe, and
fast
- make it safe and no data loss
System goals
operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient
debugging
finding and fixing errors
OS will generate log files
cooperating process
Any process that can affect or be affected by other processes
Message Passing
Data is sent from one process to another:
- Process A sends a message and is stored in the kernel
- Process B receives a message, retrieving the message from the kernel
(This models is useful for processes running on different computers)
shared memory
Memory shared between 2 processes
- Process A: Writes value to shared memory
- Process B: reads value from shared memory
(Kernel provides shared memory when requested)
Process Control Block (PCB)
Generated for each process created, contains data and metadata about process
Switching process situations (3)
Interrupt: OS wants different process to use CPU
I/O Request: process is added to I/O queue
Waiting for event: program is waiting for even to occur
Context Switch
act of switching processes
saves PCB to load saved state of process to resume after switching is done
daemons
processes waiting for work
once it receives work, it will create a process
fork() return values (2)
- pid of parent or -1 if there was an error
- child process pid which is 0
cooperating process usages (4)
info sharing
efficiency
modularity
convenience
Inter-process communication (IPC) Models
Message Passing
Shared memory
average memory latency formula
c + (1-h) * m
c: cache access time
m: time to access main memory
average memory latency formula for multi-level cache
L1 + (1-h1)(L2 + (1-h2)M)
Nonpreemptive scheduling
Process decides when to evict from CPU
preemptive scheduling
OS decides when to evict process from CPU
nonpreemptive schedulers (3)
nonpreemptive
shortest job first
first come first serve
preemptive schedulers (3)
preemptive
shortest remaining time first
round robin
FCFS pros (2) & cons (3)
pros
- no starvation
- simple to implement
cons
- wait time is not optimized
- long processes can hog resources
- Convoy effect: short processes wait behind long ones
SJF pros (2) & cons (2)
pros
- reduce average wait time : best nonpreemptive scheduler
- favors I/O bound processes
cons
- large burst time processes can starve
- long processes can hog resources
NP pros (1) & cons (2)
pros
- higher priority processes see lower wait times
cons
- processes with low priorities can starve
- long processes can hog resources
Schedulers that cause starvation
NP: SJF and NP
P: SRTF and P
(avoid starvation by providing a max wait time that applies to all processes)
SRTF pros (2) & cons (1)
pros
- fastest algorithm
- favors I/O bound processes
cons
- processes with large burst time can starve
P pros (1) & cons (1)
pros
- higher priority processes have low wait times
cons
- processes with low priorities can starve
RR pros (2) & cons (2)
pros
- starvation is not possible
- avg response time decreases
cons
- average waiting time increases
- more context switches
meta-scheduler
Multiple queues of processes require a scheduler for which queue to be picked next
time slice
allocated CPU time