Test 1 Flashcards

1
Q

Operating System

A

A program that acts as an intermediary between a user of a computer and the computer hardware
Operating system goals:
Execute user programs and make solving user problems easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner

What OSs do?
Depends on the point of view
Users want convenience, ease of use and good performance
Don’t care about resource utilization
But shared computer such as mainframe or minicomputer must keep all users happy
Users of dedicated systems such as workstations have dedicated resources but frequently use shared resources from servers
Handheld computers are resource poor, optimized for usability and battery life
Some computers have little or no user interface, such as embedded computers in devices and automobiles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

4 components of Computer System Structure

A

A computer system can be divided into four components:
Hardware – provides basic computing resources
CPU, memory, I/O devices

Operating system
Controls and coordinates use of hardware among various applications and users

Application programs – define the ways in which the system resources are used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video games

Users
People, machines, other computers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

resource allocator

A

An OS is one
Manages all resources
Decides between conflicting requests for efficient and fair resource use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

control program

A

An OS is one

Controls execution of programs to prevent errors and improper use of the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

kernel

A

“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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bootstrap program

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Computer System operation

A

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

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
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Types of Processing Units

A

CPU – Central Processing Unit

GPU – Graphics Processing Unit

TPU – Tensor Processing Unit

FPGA – Field Programmable Gate Array

ASIC – Application Specific Integrated Circuit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

CPU

A

Brain of the computer

Traditional processing unit

Responsible for most or all executed instructions

Performs operations sequentially

What’s your processor speed?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

GPU

A

Has actually been around since the 1970s

A GPU is geared toward dealing with images and graphical ‘things’

Good at matrix operations

Performs operations in parallel; has many ALUs in a single processor

GPU program: __global__ - indicates a function that runs on the device called form host code
The ‘&laquo_space;»’ mark a call from host code to device code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

TPU (Tensor Processing Unit)

A

Designated architecture for deep learning/machine learning computations

Tasks developed using TensorFlow – a programming framework

A tensor is an n-dimensional matrix. Matrix and dense vector processing.

Designed by Google around 2016

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

FGPA (Field Programmable Gate Array)

A

As the name implies, they are field programmable

Customizable for specific applications

Large datasets, high speed search (Bing search algorithms)

Can be changed to support new algorithms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ASIC Application Specific Integrated Circuit

A

A non-standard IC designed for a specific use of application

A TPU is an ASIC

Other examples:
A chip in a stuffed animal that talks
A specialized chip for a satellite
Chip in a DVD player to decode info on the disc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

interrupt vector/interrupt driven

A

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
An operating system is interrupt driven

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Interrupt handling/polling/vectored interrupt system

A

The operating system preserves the state of the CPU by storing registers and the program counter
Determines which type of interrupt has occurred:

polling (Either CPU checks at regular intervals for interrupts or it knows an interrupt has occurred and polls to see what caused it)

vectored interrupt system
Separate segments of code determine what action should be taken for each type of interrupt

Interrupts can have priorities but generally can’t be interrupted themselves.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

I/O Structure

A
After I/O starts, control returns to user program only upon I/O completion
Wait instruction idles the CPU until the next interrupt
Wait loop (contention for memory access)
At most one I/O request is outstanding at a time, no simultaneous I/O processing
After I/O starts, control returns to user program without waiting for I/O completion
System call – request to the OS to allow user to wait for I/O completion
Device-status table contains entry for each I/O device indicating its type, address, and state
OS indexes into I/O device table to determine device status and to modify table entry to include interrupt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

System Call

A

request to the OS to allow user to wait for I/O completion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Device-status table

A

contains entry for each I/O device indicating its type, address, and state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Main memory

A

Main memory – only large storage media that the CPU can access directly
Random access
Typically volatile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Secondary storage

A

extension of main memory that provides large nonvolatile storage capacity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Hard disks and SSDs

A

Hard 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
Solid-state disks (flash drives)– faster than hard disks, nonvolatile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Caching

A

Caching – copying information into a faster storage system; main memory can be viewed as a cache for secondary storage
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
Cache smaller than storage being cached
Cache management important design problem
Cache size and replacement policy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Direct memory access structure

A

Used for high-speed I/O devices able to transmit information at close to memory speeds
Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention
Only one interrupt is generated per block, rather than the one interrupt per byte
There is a DMA controller…it’s like the HW can access memory and bypass the CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Multiprocessors

A

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:
Increased throughput
Economy of scale
Increased reliability – graceful degradation or fault tolerance
Two types:
Asymmetric Multiprocessing – each processor is assigned a specific task.
Symmetric Multiprocessing – each processor performs all tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Asymmetric Multiprocessing
each processor is assigned a specific task.
26
Symmetric Multiprocessing
each processor performs all tasks
27
multicore
One chip with more than one core
28
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
29
storage-area network (SAN)
storage sharing for clustered systems
30
Asymmetric clustering
Asymmetric clustering has one machine in hot-standby mode
31
Symmetric clustering
Symmetric clustering has multiple nodes running applications, monitoring each other
32
parallelization
Some clusters are for high-performance computing (HPC) | Applications must be written to use parallelization
33
Multiprogramming (Batch system)
Multiprogramming (Batch system) needed for efficiency Single user cannot keep CPU and I/O devices busy at all times 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 it has to wait (for I/O for example), OS switches to another job Multiprogramming has to do with utilization of the CPU Timesharing has to do with sharing the CPU among users
34
Timesharing (multitasking)
Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second Each user has at least one program executing in memory 🢡process If several jobs ready to run at the same time 🢡 CPU scheduling If processes don’t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory
35
Interrupt driven (hardware and software)
Interrupt driven (hardware and software) Hardware interrupt by one of the devices Software interrupt (exception or trap): Software error (e.g., division by zero) Request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system
36
Using a timer for resource management
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
37
Dual-mode
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 Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user
38
multi-mode operations
Increasingly CPUs support multi-mode operations | i.e. virtual machine manager (VMM) mode for guest VMs
39
privileged instruction
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
40
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 needs resources to accomplish its task CPU, memory, I/O, files Initialization data 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 Typically system has many processes, some user, some operating system running concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the processes / threads `
41
passive vs active entity
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.
42
program counter
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
43
The operating system is responsible for the following activities in connection with process management
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
44
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 memory and when Optimizing CPU utilization and computer response to users 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
45
Storage Management
OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - 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 There are utilities on Linux to let you map a Windows filesystem – Samba is the most popular
46
file
Abstracts physical properties to logical storage unit - file
47
Order of fastest memory
registers > cache > main memory > SSD > Magnetic disk
48
Cache coherency
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 piece of data can exist Various solutions covered in Chapter 17
49
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
50
SPooling
Spooling can sort of be thought of as handing the job off and then continuing – we usually hear this in relation to printing. It’s like buffering, but with buffering, we’re storing data to be used by the same process.
51
Protection
any mechanism for controlling access of processes or users to resources defined by the OS ``` Systems generally first distinguish among users, to determine who can do what User identities (user IDs, security IDs) include name and associated number, one per user User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file Privilege escalation (WIndows run as admin) allows user to change to effective ID with more rights ```
52
Security
Security – defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service
53
Virus
Attaches itself to a program or file (almost always an executable) enabling it to spread from one computer to another, leaving infections as it travels. Normally doesn’t infect your computer unless it is run Cannot spread without human interaction (like running it) Attaches to an executable file, requires human action to spread
54
Worm
``` Subclass of a virus Capability to travel without human interaction - takes advantage of file or information transport features Example: Worm to send a copy of itself to everyone listed in your e-mail address book. Then, the worm replicates and repeats. May consume resources and slow computer down severely Can replicate itself on system, does not require human action to spread. ```
55
Computing Environments (traditional)
Stand-alone general purpose machines But blurred as most systems interconnect with others (i.e., the Internet) Portals provide web access to internal systems Network computers (thin clients) are like Web terminals Mobile computers interconnect via wireless networks Networking has become almost ubiquitous – even home systems use firewalls to protect home computers from Internet attacks
56
Computing Environments (mobile)
Handheld smartphones, tablets, etc What is the functional difference between them and a “traditional” laptop? Extra features – more OS features (GPS, gyroscope) Allows new types of apps like augmented reality Use IEEE 802.11 wireless, or cellular data networks for connectivity Leaders are Apple iOS and Google Android
57
Distributed computing environment
Distributed computiing Collection of separate, possibly heterogeneous, systems networked together Network is a communications path, TCP/IP most common Local Area Network (LAN) Wide Area Network (WAN) Metropolitan Area Network (MAN) Personal Area Network (PAN) Network Operating System provides features between systems across network Communication scheme allows systems to exchange messages Illusion of a single system
58
Network
``` Network is a communications path, TCP/IP most common Local Area Network (LAN) Wide Area Network (WAN) Metropolitan Area Network (MAN) Personal Area Network (PAN) ```
59
Network Operating System
Network Operating System provides features between systems across network Communication scheme allows systems to exchange messages Illusion of a single system
60
Client-Server Computing
Client-Server Computing Dumb terminals supplanted by smart PCs Many systems now servers, responding to requests generated by clients Compute-server system provides an interface to client to request services (i.e., database) File-server system provides interface for clients to store and retrieve files
61
Peer-to-Peer computing environment
Another model of distributed system P2P does not distinguish clients and servers Instead all nodes are considered peers May each act as client, server or both Node must join P2P network Registers its service with central lookup service on network, or Broadcast request for service and respond to requests for service via discovery protocol Examples include Napster and Gnutella, Voice over IP (VoIP) such as Skype
62
Virtualization
Virtualization – OS natively compiled for CPU, running guest OSes also natively compiled Consider VMware running WinXP guests, each running applications, all on native WinXP host OS VMM (virtual machine Manager) provides virtualization services Allows operating systems to run applications within other OSes Vast and growing industry Use cases involve laptops and desktops running multiple OSes for exploration or compatibility Apple laptop running Mac OS X host, Windows as a guest Developing apps for multiple OSes without having multiple systems QA testing applications without having multiple systems Executing and managing compute environments within data centers VMM can run natively, in which case they are also the host There is no general purpose host then (VMware ESX and Citrix XenServer)
63
Emulation
Emulation used when source CPU type different from target type (i.e. PowerPC to Intel x86) Generally slowest method When computer language not compiled to native code – Interpretation
64
Cloud Computing
Delivers computing, storage, even apps as a service across a network Logical extension of virtualization because it uses virtualization as the base for its functionality. Amazon EC2 has thousands of servers, millions of virtual machines, petabytes of storage available across the Internet, pay based on usage Many types Public cloud – available via Internet to anyone willing to pay Private cloud – run by a company for the company’s own use Hybrid cloud – includes both public and private cloud components Software as a Service (SaaS) – one or more applications available via the Internet (i.e., word processor) Platform as a Service (PaaS) – software stack ready for application use via the Internet (i.e., a database server) Infrastructure as a Service (IaaS) – servers or storage available over Internet (i.e., storage available for backup use) Cloud computing environments composed of traditional OSes, plus VMMs, plus cloud management tools Internet connectivity requires security like firewalls Load balancers spread traffic across multiple applications
65
Real-time embedded systems
Real-time embedded systems most prevalent form of computers Vary considerably, special purpose, limited purpose OS, real-time OS Use expanding Many other special computing environments as well Some have OSes, some perform tasks without an OS Real-time OS has well-defined fixed time constraints Processing must be done within constraint Correct operation only if constraints met
66
Open-Source Operating Systems
Operating systems made available in source-code format rather than just binary closed-source Counter to the copy protection and Digital Rights Management (DRM) movement Started by Free Software Foundation (FSF), which has “copyleft” GNU Public License (GPL) Examples include GNU/Linux and BSD UNIX (including core of Mac OS X), and many more Can use VMM like VMware Player (Free on Windows), Virtualbox (open source and free on many platforms - http://www.virtualbox.com) Use to run guest operating systems for exploration
67
OPerating system services (helpful to user)
Operating systems 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 systems 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
68
User interface
User interface - Almost all operating systems have a user interface (UI). Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch
69
Program execution
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)
70
I/O operations
I/O operations - A running program may require I/O, which may involve a file or an I/O device
71
File-system manipulation
File-system manipulation - The file system is of particular interest. Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
72
Communications
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)
73
Error detection
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
74
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 - CPU cycles, main memory, file storage, I/O devices. Accounting - To keep track of which users use how much and what kinds of computer resources 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
75
CLI or command line interpreter
CLI or command line interpreter allows direct command entry Sometimes implemented in kernel, sometimes by systems program Sometimes multiple flavors implemented – shells Primarily fetches a command from user and executes it Sometimes commands built-in, sometimes just names of programs If the latter, adding new features doesn’t require shell modification
76
User-friendly desktop metaphor interface
User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder) Invented at Xerox PARC Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI “command” shell Apple Mac OS X is “Aqua” GUI interface with UNIX kernel underneath and shells available Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)
77
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)
78
System-call interface
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 Managed by run-time support library (set of functions built into libraries included with compiler)
79
System call 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 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 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
80
Status information system program
Status information Some ask the system for info - date, time, amount of available memory, disk space, number of users Others provide detailed performance, logging, and debugging information Typically, these programs format and print the output to the terminal or other output devices Some systems implement a registry - used to store and retrieve configuration information
81
System program features
File modification Text editors to create and modify files Special commands to search contents of files or perform transformations of the text Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes provided Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systems Allow users to send messages to one another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another
82
System program background services
``` Background Services Launch at boot time Some for system startup, then terminate Some from system boot to shutdown Provide facilities like disk checking, process scheduling, error logging, printing Run in user context not kernel context Known as services, subsystems, daemons ```
83
system program Application programs
``` Application programs Don’t pertain to system Run by users Not typically considered part of OS Launched by command line, mouse click, finger poke ```
84
User goals and System goals
User goals and System goals 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
85
Policy vs Mechanism
Important principle to separate Policy: What will be done? Mechanism: How to do it? Mechanisms determine how to do something, policies decide what will be done The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later (example – timer) Specifying and designing an OS is highly creative task of software engineering
86
OS languages
Much variation Early OSes in assembly language Then system programming languages like Algol, PL/1 Now C, C++ Actually usually a mix of languages Lowest levels in assembly Main body in C Systems programs in C, C++, scripting languages like PERL, Python, shell scripts More high-level language easier to port to other hardware But slower Emulation can allow an OS to run on non-native hardware
87
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
88
Microkernel System Structure
Moves as much from the kernel into user space as possible 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
89
loadable kernel modules
Many modern operating systems 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 more flexible Linux, Solaris, etc
90
Hybrid Systems
Most modern operating systems are actually not one pure model Hybrid combines multiple approaches to address performance, security, usability needs Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality Windows mostly monolithic, plus microkernel for different subsystem personalities Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions) monolithic In kernel architecture, describes a kernel without structure (such as layers or modules).
91
Monolithic kernel
A monolithic kernel is an operating system architecture where the entire operating system is working in kernel space
92
OS Debugging
Debugging is finding and fixing errors, or bugs OS generate log files containing error information Failure of an application can generate core dump file capturing memory of the process Operating system failure can generate crash dump file containing kernel memory Beyond crashes, performance tuning can optimize system performance Sometimes using trace listings of activities, recorded for analysis Profiling is periodic sampling of instruction pointer to look for statistical trends Kernighan’s Law: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
93
Performance Tuning
Improve performance by removing bottlenecks OS must provide means of computing and displaying measures of system behavior For example, “top” program or Windows Task Manager DTrace tool in Solaris, FreeBSD, Mac OS X allows live instrumentation on production systems
94
System Boot
When power initialized on system, execution starts at a fixed memory location Firmware ROM used to hold initial boot code Operating system must be made available to hardware so hardware can start it Small piece of code – bootstrap loader, stored in ROM or EEPROM locates the kernel, loads it into memory, and starts it Sometimes two-step process where boot block at fixed location loaded by ROM code, which loads bootstrap loader from disk Common bootstrap loader, GRUB, allows selection of kernel from multiple disks, versions, kernel options Kernel loads and system is then running
95
Process Concept (parts of process)
An operating system executes a variety of programs: Batch system – jobs Time-shared systems – user programs or tasks Textbook uses the terms job and process almost interchangeably Process – a program in execution; process execution must progress in sequential fashion Multiple parts The program code, also called text section Current activity including program counter, processor registers Stack containing temporary data Function parameters, return addresses, local variables Data section containing global variables Heap containing memory dynamically allocated during run time Program is passive entity stored on disk (executable file), process is active Program becomes process when executable file loaded into memory Execution of program started via GUI mouse clicks, command line entry of its name, etc One program can be several processes Consider multiple users executing the same program
96
Process State
As a process executes, it changes state new: The process is being created running: Instructions are being executed waiting: The process is waiting for some event to occur ready: The process is waiting to be assigned to a processor terminated: The process has finished execution
97
Process Control Block (PCB)
Information associated with each process (also called task control block) Process state – running, waiting, etc Program counter – location of instruction to next execute CPU registers – contents of all process-centric registers CPU scheduling information- priorities, scheduling queue pointers Memory-management information – memory allocated to the process Accounting information – CPU used, clock time elapsed since start, time limits I/O status information – I/O devices allocated to process, list of open files
98
Threads
So far, process has a single thread of execution Consider having multiple program counters per process Multiple locations can execute at once Multiple threads of control -> threads Must then have storage for thread details, multiple program counters in PCB See next chapter
99
Processor Scheduling
Maximize CPU use, quickly switch processes onto CPU for time sharing Process scheduler selects among available processes for next execution on CPU Maintains scheduling queues of processes Job queue – set of all processes in the system Ready queue – set of all processes residing in main memory, ready and waiting to execute Device queues – set of processes waiting for an I/O device Processes migrate among the various queues
100
Schedulers
Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU Sometimes the only scheduler in a system Short-term scheduler is invoked frequently (milliseconds) ⇒ (must be fast) Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue Long-term scheduler is invoked infrequently (seconds, minutes) ⇒ (may be slow) The long-term scheduler controls the degree of multiprogramming Processes can be described as either: I/O-bound process – spends more time doing I/O than computations, many short CPU bursts CPU-bound process – spends more time doing computations; few very long CPU bursts Long-term scheduler strives for good process mix
101
Mobile multitasking
Some mobile systems (e.g., early version of iOS) allow only one process to run, others suspended Due to screen real estate, user interface limits iOS provides for a Single foreground process- controlled via user interface Multiple background processes– in memory, running, but not on the display, and with limits Limits include single, short task, receiving notification of events, specific long-running tasks like audio playback Android runs foreground and background, with fewer limits Background process uses a service to perform tasks Service can keep running even if background process is suspended Service has no user interface, small memory use
102
Context Switch
When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch Context of a process represented in the PCB Context-switch time is overhead; the system does no useful work while switching The more complex the OS and the PCB 🡺 the longer the context switch Time dependent on hardware support Some hardware provides multiple sets of registers per CPU 🡺 multiple contexts loaded at once
103
Process Creation
Parent process create children processes, which, in turn create other processes, forming a tree of processes Generally, process identified and managed via a process identifier (pid) Resource sharing options Parent and children share all resources Children share subset of parent’s resources Parent and child share no resources Execution options Parent and children execute concurrently Parent waits until children terminate ``` Address space Child duplicate of parent Child has a program loaded into it UNIX examples fork() system call creates new process exec() system call used after a fork() to replace the process’ memory space with a new program ```
104
Process termination
Process executes last statement and then asks the operating system to delete it using the exit() system call. Returns status data from child to parent (via wait()) Process’ resources are deallocated by operating system Parent may terminate the execution of children processes using the abort() system call. Some reasons for doing so: Child has exceeded allocated resources Task assigned to child is no longer required The parent is exiting and the operating systems does not allow a child to continue if its parent terminates
105
cascading termination
Some operating systems do not allow child to exists if its parent has terminated. If a process terminates, then all its children must also be terminated. cascading termination. All children, grandchildren, etc. are terminated. The termination is initiated by the operating system. The parent process may wait for termination of a child process by using the wait()system call. The call returns status information and the pid of the terminated process pid = wait(&status); If no parent waiting (did not invoke wait()) process is a zombie If parent terminated without invoking wait , process is an orphan If the parent didn’t invoke wait, the child exit status is in the process table – reading that code is called “reaping” the child. The child is a zombie until that happens. If the parent terminates before the child, the child is considered an orphan.
106
Interprocess Communication
Processes within a system may be independent or cooperating Cooperating process can affect or be affected by other processes, including sharing data Reasons for cooperating processes: Information sharing Computation speedup Modularity Convenience Cooperating processes need interprocess communication (IPC) Two models of IPC Shared memory Message passing Independent process cannot affect or be affected by the execution of another process Cooperating process can affect or be affected by the execution of another process
107
Producer Consumer Problem
Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process unbounded-buffer places no practical limit on the size of the buffer bounded-buffer assumes that there is a fixed buffer size -> can only use n - 1 of buffer size b/c buffer is empty when in == out
108
Shared Memory
An area of memory shared among the processes that wish to communicate The communication is under the control of the users processes not the operating system. Major issue is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory. Synchronization is discussed in great details in Chapter 5.
109
Message Passing
Mechanism for processes to communicate and to synchronize their actions Message system – processes communicate with each other without resorting to shared variables IPC facility provides two operations: send(message) receive(message) The message size is either fixed or variable If processes P and Q wish to communicate, they need to: Establish a communication link between them Exchange messages via send/receive ``` Implementation of communication link Physical: Shared memory Hardware bus Network Logical: Direct or indirect Synchronous or asynchronous Automatic or explicit buffering ```
110
Direct Communication
Processes must name each other explicitly: send (P, message) – send a message to process P receive(Q, message) – receive a message from process Q Properties of communication link Links are established automatically A link is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi-directional
111
Indirect Communication
Messages are directed and received from mailboxes (also referred to as ports) Each mailbox has a unique id Processes can communicate only if they share a mailbox Properties of communication link Link established only if processes share a common mailbox A link may be associated with many processes Each pair of processes may share several communication links Link may be unidirectional or bi-directional Operations create a new mailbox (port) send and receive messages through mailbox destroy a mailbox Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A Mailbox sharing P1, P2, and P3 share mailbox A P1, sends; P2 and P3 receive Who gets the message? Solutions Allow a link to be associated with at most two processes Allow only one process at a time to execute a receive operation Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.
112
Synchronization
Message passing may be either blocking or non-blocking Blocking is considered synchronous Blocking send -- the sender is blocked until the message is received Blocking receive -- the receiver is blocked until a message is available Non-blocking is considered asynchronous Non-blocking send -- the sender sends the message and continue Non-blocking receive -- the receiver receives: A valid message, or Null message Different combinations possible If both send and receive are blocking, we have a rendezvous
113
Buffering
Queue of messages attached to the link. implemented in one of three ways 1. Zero capacity – no messages are queued on a link. Sender must wait for receiver (rendezvous) 2. Bounded capacity – finite length of n messages Sender must wait if link full 3. Unbounded capacity – infinite length Sender never waits
114
Sockets
A socket is defined as an endpoint for communication Concatenation of IP address and port – a number included at start of message packet to differentiate network services on a host The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 Communication consists between a pair of sockets All ports below 1024 are well known, used for standard services Special IP address 127.0.0.1 (loopback) to refer to system on which process is running Three types of sockets Connection-oriented (TCP) Connectionless (UDP) MulticastSocket class– data can be sent to multiple recipients
115
Remote Procedure Calls
Remote procedure call (RPC) abstracts procedure calls between processes on networked systems Again uses ports for service differentiation Stubs – client-side proxy for the actual procedure on the server The client-side stub locates the server and marshalls the parameters The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server
116
Ordinary pipes
Acts as a conduit allowing two processes to communicate – cannot be accessed from outside the process that created it. Typically, a parent process creates a pipe and uses it to communicate with a child process that it created. Ordinary Pipes allow communication in standard producer-consumer style Producer writes to one end (the write-end of the pipe) Consumer reads from the other end (the read-end of the pipe) Ordinary pipes are therefore unidirectional Require parent-child relationship between communicating processes Windows calls these anonymous pipes See Unix and Windows code samples in textbook
117
Named pipes
– can be accessed without a parent-child relationship. Named Pipes are more powerful than ordinary pipes Communication is bidirectional No parent-child relationship is necessary between the communicating processes Several processes can use the named pipe for communication Provided on both UNIX and Windows systems