C191-Terms-Chapter-1-2 Flashcards
Operating System (OS)
The software runs on the bare hardware of a computer and provides essential support for users to develop and use applications in the most efficient and safe manner.
An OS provides an environment for the execution of programs. It makes certain services available to programs and to the users of those programs.
What are the goals of the OS?
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 are the four components of a computer system?
- Hardware (lowest level) - provides basic computing resources such as CPU, memory, and I/O devices.
- OS - controls and coordinates the use of the hardware among applications and users.
- Application Programs - define the ways in which the system resources are used to solve the computing problems of the users. These include Word processors, compilers, web browsers, database systems, and video games.
- Users - people, machines, and other computers.
The OS as a resource manager
- Manages all resources.
- Decide between conflicting requests for efficient and fair resource use.
One of the main tasks of an OS is to optimize the use of all computational resources to ensure good overall performance, while satisfying the requirements of specific applications, including guaranteeing acceptable response times for interactive processes, meeting deadlines of time-critical tasks, and allowing safe communication among different tasks.
The OS is a control program
The OS controls the execution of programs to prevent errors and improper use of the computer.
Bootstrap Program
It’s loaded at power-up or reboot.
- First program to run when the computer
powers on, which then loads the OS.
- Typically stored in ROM or EPROM, generally known as firmware.
- Initializes all aspects of the system.
- Loads the OS kernel and starts execution.
Computer-system operation
One or more CPUs and device controllers connect through a common bus providing access to shared memory.
Concurrent execution of CPUs and devices competing for memory cycles.
The CPU and device controllers can run concurrently and compete for memory cycles.
I/O devices and the CPU can execute concurrently.
Each device controller is in charge of a specific device type.
Each device controller has a local buffer.
The CPU moves data from/to main memory to/from local buffers.
I/O is from the device to the local buffer of the controller.
The device controller informs the CPU that it has finished its operation by causing an
interrupt.
Interrupts
An interrupt is an event that diverts the current execution of a program to a predefined location in the kernel in order to respond to an event.
An interrupt is triggered by a hardware signal sent to the CPU from an external device.
The two most common uses of interrupts are as follows:
- Signal to the OS for the completion of an I/O operation. The interrupt is generated by the I/O device.
- Implement time-sharing by periodically switching the CPU among multiple concurrent computations. The interrupt is generated by a countdown timer.
Common Functions of Interrupts
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.
Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.
A trap is a software-generated interrupt caused either by an error or a user request.
An OS is interrupt driven.
Interrupt Handler
A kernel function invoked whenever an interrupt occurs determines the cause of the interrupt and invokes the appropriate kernel function to provide the response.
When the kernel function completes the requested service, the state of the interrupted computation is restored and control is returned to the instruction following the interrupt.
The handling of an interrupt is thus completely transparent to the interrupted computation and provides an immediate response to asynchronous events.
Interrupt Handling
The OS preserves the state of the CPU by storing registers and the program counter.
Determines which type of interrupt has occurred:
- Polling
- Vectored interrupt system
Separate segments of code determine what action should be taken for each type of interrupt.
I/O Structure
After I/O starts, control returns to the user program only upon I/O completion. This I/O method is called synchronous.
- Wait instruction idles the CPU until the next attempt.
- 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 the user program without waiting for I/O completion. This I/O method is called asynchronous.
- System call: request to the OS to allow the user (to do something) to wait for I/O completion.
- Device- status table: contains an entry for each I/O device indicating its type, address, and state.
- The OS indexes into the I/O device table to determine device status and to modify table entry to include interrupt.
I/O Storage
Main memory - the only large storage media that the CPU can access directly.
Secondary storage - an extension of the 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.
CPU
Hardware capabilities - machine instructions perform operations on contents of registers and memory locations.
User needs - The user thinks in terms of
arrays, lists, and other high-level data structures accessed and
manipulated by corresponding high-level operations.
Main memory
Hardware capabilities - physical memory is a linear sequence of addressable bytes or words that hold programs and data.
User needs - the user must manage a heterogeneous collection of entities of various types and sizes, including source and executable programs, library functions, and dynamically allocated data structures, each accessed by different operations.
Secondary storage
Hardware capabilities - disks and other secondary storage devices are multi-dimensional structures, which require complex sequences of low-level operations to store and access data organized in discrete blocks.
User needs - the user needs to access and
manipulate programs and data sets of various sizes as individual named entities without any knowledge of the disk organization.
I/O devices
Hardware capabilities - I/O devices are operated by reading and writing registers of the device controllers.
User needs - the user needs simple, uniform interfaces to access different devices without detailed knowledge of the access and communication protocols.
Abstraction
Abstraction is the act of removing unimportant details or attributes of objects in order to construct more general and less complex objects.
OSs make extensive use of abstraction by creating hierarchies of objects where multiple operations at one level are
combined into a single operation at a higher level, thus hiding the details of the implementation and making the operation easier to use.
Virtualization
Virtualization is the act of creating the illusion of having one or more objects with more desirable characteristics than the real object.
OSs rely on virtualization to create virtual CPUs, memory, I/O devices, and other system components that facilitate the work of programmers and users.
Abstraction and Virtualization
The concepts of abstraction and virtualization are closely related. Abstraction emphasizes combining simpler objects or operations to create objects with expanded functionality.
Virtualization may use abstraction but emphasizes diversifi cation and replication by creating illusions of objects with more favorable characteristics.
An OS is thus an extended machine, which provides e fficient high-level functions and virtual entities that liberate the programmer and the user from having to understand details of memory, disk, I/O management, and other internal processes.
Multiprogramming
A technique that keeps several programs active in memory and switches execution among the different programs to maximize the use of the CPU and other resources.
Whenever a program enters an I/O-bound phase where little CPU time is needed, other programs can resume and utilize the CPU in the meantime.
Similarly, whenever a device completes an operation, the OS activates computations that can utilize the now available device.
Time-sharing (multitasking)
An extension of multiprogramming where the CPU is switched periodically among all active computations to guarantee acceptable response times to each user.
Time-sharing employs the concept of virtualization by creating the illusion of having a separate virtual CPU for each computation.
Kernel
The min set of functions that is necessary to manage the system resources safely and efficiently.
The kernel provides the most essential services for memory and device management, creating and managing units of computation, and communication among the different concurrent activities within the system.
The functionality of the kernel is extended by a set of libraries, which use kernel functions to implement higher-level system functions.
Additional libraries provide a wide range of other services to the users by supporting abstractions above the system calls. Applications and system software, including editors, compilers, and interpreters, form the highest layer of software.
Depending on the type of application or service, software at the top level may use library services, issue system calls, or invoke kernel services directly.
Privileged instruction
Performs critical operations that access I/O devices and the CPU’s status and control registers. Thus only the OS kernel is allowed to execute privileged instructions.
Kernel mode
The CPU state where both privileged and non-privileged instructions may be used.
Any attempt to execute a privileged instruction in user mode automatically transfers control to the kernel.
User mode
The CPU state where only non-privileged instructions may be used.
GUI or Graphical User Interface
Presets various icons on the screen, which the user can click on in different ways to invoke services associated with the icons, or to reveal pull-down menus for additional tasks.
The main advantage of a GUI is the intuitive visual representation of objects. A user is able to manipulate objects and invoke operations using a mouse without much training and without any knowledge of the underlying commands.
OS Shell
A command interpreter that accepts and interprets textual commands issued by the user via a keyboard.
Any shell offers dozens of commands, each having various optional parameters, fags, and other modifiers to provide a wide spectrum of operations.
Common Windows commands:
DIR - displays a list of files and subdirectories in a directory (folder).
COPY - Copy one or more files to another location.
WC - Count the number of words, lines, and characters in a text file.
DEL - Delete one or more files
A shell is preferred by programmers and expert users because text-based commands are more flexible than icons by providing a range of parameters and control flags to modify each command.
Multiple commands can be combined using conditional, iterative, and logic constructs to handle complex tasks e efficiently. Ex: any number of files of different types can be moved, renamed, or selectively copied in a single loop.
The user can create and save higher-level operations following the principles of abstraction.
- A shell script is a program that implements a new operation by combining multiple commands and control statements into one named unit interpreted by the shell.
Shell script
A program that implements a new operation by combining multiple commands and control statements into one named unit interpreted by the shell.
System call
A request from an application for an OS service. A system call is implemented as a library function, which sets up the necessary parameters for the requested operation and issues a corresponding supervisor call.
Supervisor call or kernel call
A privileged instruction that automatically transfers execution control to a well-de ned location within the OS kernel. Thus supervisor calls provide the interface between the OS kernel and the higher-level software.
A supervisor call is similar to a function call with two special features:
1. The call switches execution from user mode to kernel mode by setting the mode bit in the CPU.
2.To prevent a call from branching to arbitrary locations within the kernel, the function to be invoked is not specified by an address but indirectly using an index into a
branch vector.
Thus kernel-mode execution is limited to only well-de ned entry points within the kernel.
When the kernel function terminates, control is returned to the invoking library function in user mode. Control may return immediately or may be delayed by blocking the invoking computation to await the completion of some event.
The system call library function then returns control to the application, also in user mode.
Execution of a system call
- An application, running in user mode, executes a system call S() to request a service from the OS.
- Execution transfers to the library function S(), still in user mode.
- S sets up the parameters for the service and executes the privileged
instruction supervisor_call. The parameter k identifies the kernel function using a branch vector in the kernel. - Execution transfers to the kernel function in kernel mode, which allows the
CPU to use privileged instructions. - When the kernel function completes the requested service, execution
returns to the system call function S in user mode. - The system call function completes the request and returns to the
application at the instruction following S().
Trap or internal interrupt
An interrupt triggered by the currently executing instruction. Dividing by zero, executing an invalid opcode, or causing an arithmetic overflow are all errors, which result in a trap and cause the OS to abort the current program execution.
Executing a supervisor call instruction is not an error but also causes a trap since the main purpose is to transfer control to the kernel when requesting a service.
An interrupt, both external and internal, stops the execution of the current program, saves the state of the computation, and transfers control to the kernel.
Moore’s law
Formulated by the scientist Gordon Moore, is the observation that the number of transistors in an integrated circuit doubles about every two years. This prediction has held steady since the mid-1960s until today.
First-generation-computers
Used vacuum tubes.
No OS type.
All programming was done by experts in machine language without any support from an OS or any other system software.
Second-generation-computers
Transistors replaced vacuum tubes as smaller and faster switches.
Batch OS.
Programs were submitted in batches of punch cards. The role of the OS was to automate the compilation, loading, and execution of programs.
Multiprogramming was developed, which allows the OS to schedule the execution of jobs to make more efficient use of the CPU and other resources.
Third-generation-computers
Integrated circuits allowed the development of microchips to replace individual transistors.
Interactive multi-user OS.
Interrupts were developed to allow the OS to enforce time-sharing and to interact with keyboards and display terminals, also developed during the same period.
Increased capacity and speed of memory and secondary storage devices imposed additional management tasks on the OS.
Fourth-generation-computers
Very-large-scale integration (VLSI) allowed the placement of a complete microprocessor on a single chip, leading to the development of personal computers (PCs).
Desktops and laptops OS.
The OS was responsible for all operations, starting from the initial booting to multitasking, scheduling, interactions with various peripheral devices, and keeping all information safe.
The emphasis was on user-friendliness, including the introduction of the GUI.
Fifth-generation-computers
Networking hardware enabled the harnessing of the power of multiple computers.
OSs for supercomputers, distributed systems, and mobile devices.
The ability to create powerful chips led to several directions of development. Supercomputers combined large numbers of processors and made the OS and other software responsible for exploiting the increased computation power through parallel processing.
Computer networks gave rise to the Internet, which imposed privacy and safety requirements along with efficient communication.
Wireless networks led to the development of hand-held devices.
Mainframe
A large central computer used by large organizations.
High-volume data processing in administration, banking, and government.
High throughput, management of large storage.
Server
A large computer that responds to requests from individual clients.
Web and email processing, Internet commerce.
Fast response, security.
Multiprocessor
A system of multiple CPUs and memories interconnected by a fast network into a single parallel computer.
Scienti c and other high-performance computations.
Fast interprocess communication and memory access. Data consistency.
Distributed system (multi-computer)
A network of independent computers interconnected via a communication network.
Sharing of data and services, internet commerce.
Efficient and secure communication. Support for many types of applications and services.
Desktop or laptop
A personal computer.
Word processing, personal nance, access to the Internet, games.
User-friendly interface. Intuitive organization of data and applications. Support for a variety of tasks without much technical knowledge of the inner functioning of the computer.
Hand-held device
Small, portable, wireless-capable device for personal use.
Smartphones, tablets.
User-friendly interface.Easy integration of new applications. Support for microphone, speaker, camera, GPS, motion sensor, and other components.
Real-time system
A computer, frequently embedded in a larger electro-mechanical system, must respond rapidly to external events.
Control of industrial processes, vehicle and aircraft control, and audio and video transmission.
Scheduling to meet all deadlines. Reliability in life-critical applications.
Sensor network
A collection of small, spatially distributed dedicated sensors communicating by wired or wireless connections.
Industrial, environmental, or military monitors. Wearable devices.
Minimize power consumption. Form ad- hoc connections and tolerate node failures.
System bus
Provides access between different system components and shared memory.
In a communication system; e.g., within a computer, a bus connects various components, such as the CPU and I/O devices, allowing them to transfer data and commands.
Device driver
An OS component that provides uniform access to various devices and manages I/O to those devices.
OSs have a device driver for each device controller. This device driver understands the device controller and provides the rest of the operating system with a uniform interface to the device.
The CPU and the device controllers can execute in parallel, competing for memory cycles.
Device controller
Each device controller is in charge of a specific type of device (for example, a disk drive, audio device, or graphics display).
Depending on the controller, more than one device may be attached. For instance, one system USB port can connect to a USB hub, to which several devices can connect.
A device controller maintains some local buffer storage and a set of special-
purpose registers.
The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage.
A program performing I/O
To start an I/O operation, the device driver loads the correct registers in the device controller.
The device controller, in turn, examines the contents of these registers to determine what action to take (such as “read a character from the keyboard”).
The controller starts the transfer of data from the device to its local buffer. Once the transfer of data is complete, the device controller informs the device driver that it has finished its operation.
The device driver then gives control to other parts of the operating system, possibly returning the data or a pointer to the data if the operation was a read.
The device controller informs the device driver it has finished its operation via an interrupt
Interrupt overview
Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus.
(There may be many buses within a computer system, but the system bus is the main communication path between the major components.)
Interrupts are used for many other purposes as well and are a key part of how operating systems and hardware interact.
When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fixed location.
The fixed location usually contains the starting address where the service routine for the interrupt is located.
The interrupt service routine executes; on completion, the CPU resumes the interrupted computation.
Common interrupt mechanisms
The interrupt must transfer control to the correct interrupt service routine. The simple method for managing this transfer would be to invoke a generic routine to examine the interrupt information.
The routine would then call the interrupt-specific handler. But interrupts occur very often so they must be handled quickly.
A table of pointers to interrupt routines can be used instead to provide the needed speed. The interrupt routine is called indirectly through the table, with no intermediate routine needed.
These locations hold the addresses of the interrupt service routines for the various devices.
This array, or interrupt vector, of addresses is then indexed by a unique number, given with the interrupt request, to provide the address of the interrupt service routine for the interrupting device.
Operating systems as different as Windows and UNIX dispatch interrupts in this manner.
The interrupt architecture must also save the state info of whatever was interrupted so that it can restore it after servicing the interrupt.
If the interrupt routine needs to modify the processor state—for instance, by modifying register values—it must save the current state and then restore that state before returning.
After the interrupt is serviced, the saved return address is loaded into the program counter, and the interrupted computation resumes as though the interrupt had not occurred.
Interrupt-request line
The hardware connection to the CPU on which interrupts are signaled.
Interrupt-handler routine
An operating system routine that is called when an interrupt signal is received.
Basic interrupt mechanism
The CPU hardware senses the interrupt-request line after executing every instruction.
When it detects that a controller has asserted a signal on the request line, it reads the interrupt and jumps to the interrupt-handler routine by using the interrupt number as an index into the interrupt vector.
It then starts execution at the address associated with that index. The interrupt handler saves any state that it’ll change during its operation, determines the cause of the interrupt, performs the needed processing, performs a state restore, and executes a return_from_interrupt instruction to return the CPU to the execution state prior to the interrupt.
Interrupt-handling features for modern computers
- We need the ability to defer interrupt handling during critical processing.
- We need an efficient way to dispatch to the proper interrupt handler for a device.
- We need multilevel interrupts so that the operating system can distinguish between high- and low-priority interrupts and can respond with the appropriate degree of urgency.
In modern computer hardware, these three features are provided by the CPU and the
interrupt-controller hardware.
Nonmaskable interrupt
Reserved for events such as unrecoverable memory errors.
Maskable interrupt
It can be turned off by the CPU before the execution of critical instruction sequences that must not be interrupted.
The maskable interrupt is used by device controllers to request service.
Interrupt chaining
A mechanism by which each element in an interrupt vector points to the head of a list of interrupt handlers, which are called individually until one is found to service the interrupt request.
This structure is a compromise between the overhead of a huge interrupt table and the inefficiency of dispatching to a single interrupt handler.
Computers have more devices (and, hence, interrupt handlers) than they have address elements in the interrupt vector. A common way to solve this problem is to use interrupt chaining
Interrupt priority levels
These levels enable the CPU to defer the handling of low-priority interrupts without masking all interrupts and make it possible for a high-priority interrupt to preempt the execution of a low-priority interrupt.
Interrupts are used throughout modern operating systems to handle asynchronous events.
Device controllers and hardware faults raise interrupts. To enable the most urgent work to be done first, modern computers use a system of interrupt priorities.
Because interrupts are used so heavily for time-sensitive processing, efficient interrupt handling is required for good system performance.
RAM or random-access memory
The CPU can load instructions only from memory, so any programs must first be loaded into memory to run.
General-purpose computers run most of their programs from rewritable memory, called main memory (also called random-access memory, or RAM).
DRAM or dynamic-access memory
Main memory commonly is implemented in a semiconductor technology called DRAM.
Volatile
Memory storage that loses its content when power is turned off or otherwise lost.
Firmware
Storage that is infrequently written to and is nonvolatile. EEPROM can be changed but cannot be changed frequently. Additionally, it’s slow speed, so it contains mostly static programs and data that aren’t frequently used.
For example, the iPhone uses EEPROM to store serial numbers and hardware information about the device.
Bit
The basic unit of computer storage. A bit can contain one of two values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent: numbers, letters, images, movies, sounds, documents, and programs, to name a few.
Byte
8 bits, and on most computers, it is the smallest convenient chunk of storage. Each byte has its own address.
Interaction is achieved through a sequence of load or store instructions to specific memory addresses.
For example, most computers don’t have an instruction to move a bit but do have one to move a byte.
Word
A given computer architecture’s native unit of data. A word is made up of one or more bytes.
For example, a computer that has 64-bit registers and 64-bit memory addressing typically has 64-bit (8-byte) words.
A computer executes many operations in its native word size rather than a byte at a time.
Load instruction
Moves a byte or word from main memory to an internal register within the CPU.
Store instruction
Moves the content of a register to the main memory.
Aside from explicit loads and stores, the CPU automatically loads instructions from main memory for execution from the location stored in the program counter.
von Neumann architecture
The structure of most computers, which both process instructions and data are stored in the same main memory.
An instruction-execution cycle, as executed on a system with a von Neumann architecture, first fetches an instruction from memory and stores that instruction in the instruction register.
The instruction is then decoded and may cause operands to be fetched from memory and stored in some internal register. After the instruction on the operands has been executed, the result may be stored back in memory.
The memory unit sees only a stream of memory addresses. It doesn’t know how they’re generated or what they’re for.
Thus, we can ignore how a memory address is generated by a program. We’re only interested in the sequence of memory addresses generated by the running program.
Secondary storage
An extension of main memory. The main requirement for secondary storage is that it is able to hold large quantities of data permanently.
The most common secondary-storage devices are hard-disk drives (HDDs) and nonvolatile memory (NVM) devices, which provide storage for both programs and data.
Most programs (system and application) are stored in secondary storage until they are loaded into memory.
Secondary storage is also much slower than main memory. Hence, the proper management of secondary storage is of central importance to a computer system.
Tertiary storage
A type of storage that is slower and cheaper than main memory or secondary storage; frequently magnetic tape or optical disk.
Often used for special purposes such as storing backup copies of material stored on other devices.
Semiconductor memory
The top four levels of memory including registers, cache, main memory, and NVM are constructed using semiconductor memory, which consists of semiconductor-based electronic circuits.
NVM devices, at the fourth level, have several variants but in general, are faster than hard disks.
The most common form of NVM device is flash memory, which is popular in mobile devices such as smartphones and tablets. Increasingly, fl ash memory is being used for long-term storage on laptops, desktops, and servers as well.
NVM or nonvolatile memory
Nonvolatile storage retains its contents when power is lost. This type of storage can be classified into two distinct types:
Mechanical. Examples of such storage systems are HDDs, optical disks, holographic storage, and magnetic tape.
Electrical. Examples of such storage systems are flash memory, FRAM, NRAM, and SSD.
Mechanical storage is generally larger and less expensive per byte than electrical storage. Conversely, electrical storage is typically costly, smaller, and faster than mechanical storage.
The design of a complete storage system must balance all the factors just discussed: it must use only as much expensive memory as necessary while providing as much inexpensive, nonvolatile storage as possible.
Caches can be installed to improve performance where a large disparity in access time or transfer rate exists between two components.
Direct memory access (DMA)
A resource-conserving and performance-improving operation for device controllers allowing devices to transfer large amounts of data directly to and from main memory.
The form of interrupt-driven I/O described in Section Interrupts is fine for moving small amounts of data but can produce high overhead when used for bulk data movement such as NVS I/O.
To solve this problem, direct memory access (DMA) is used. After setting up buffers, pointers, and counters for the I/O device, the device controller transfers an entire block of data directly to or from the device and main memory, without CPU intervention.
Only one interrupt is generated per block, to tell the device driver that the operation has completed, rather than the one interrupt per byte generated for low-speed devices.
While the device controller is performing these operations, the CPU is available to accomplish other work.
Some high-end systems use switch rather than bus architecture. On these systems, multiple components can talk to other components concurrently, rather than competing for cycles on a shared bus. In this case, DMA is even more effective.
Interrupt vector
An operating-system data structure indexed by interrupt address and pointing to the interrupt handlers.
A kernel memory data structure that holds the addresses of the interrupt service routines for the various devices.
Hard disk drive (HDD)
A secondary storage device based on mechanical components, including spinning magnetic media platters and moving read-write heads.
Devices
Persistent storage based on circuits and electric charges.
Nonvolatile memory (NVM)
Persistent storage based on circuits and electric charges.
Portals
Gateways between requestors and services running on provider computers.
Network computer
A limited computer that understands only web- based computing.
Thin client
A limited computer (terminal) used for web-based computing.
Wireless network
A communication network composed of radio signals rather than physical wires.
Firewall
A computer, appliance, process, or network router that sits between trusted and untrusted systems or devices. It protects a network from security breaches by managing and blocking certain types of communications.
Mobile computing
A mode of computing involving small portable devices like smartphones and tablet computers.
Apple iOS
The mobile operating system created by Apple Inc.
Google Android
The mobile operating system created by Google Inc.