Operating Systems Structures and Processes Flashcards
• To describe the services an operating system provides to users, processes, and other systems. • To understand: • What is meant by Process in an operating systems sense • The composition of a process and how a process is scheduled in an operating system
Operating system services
- An operating system provides the environment within which programs
are executed. - It provides certain services to programs and to the users of those
programs. The specific services provided differ from one operating
system to another, but there are common classes
Types of Operating system services
User interface
Program execution
I/O operations
File-system manipulation
Communications
Error detection.
Resource allocation
Accounting
Protection and security
Operating system services User interface
- Almost all operating systems have a user interface (UI). Can have a command-
line interface (CLI), a batch interface, and/or a graphical user interface (GUI)
Operating system services Program execution
- The system must be able to load a program into memory and to run that
program. The program must be able to end its execution, either normally or
abnormally (indicating error)
Operating system services
Operating system service I/O operations
- A running program may require I/O, which may involve a file or an I/O device
(e.g. screen, DVD, etc.). Users usually cannot control I/O devices directly.
Therefore, the operating system must provide a means to do I/O.
Operating system services File-system manipulation
- Programs need to read and write files and directories. They also need to create
and delete them by name, search for a given file, and list file information.
Finally, some operating systems include permissions management to allow or
deny access to files or directories based on file ownership
Operating system services Communications
- There are many circumstances in which one process needs to exchange
information with another process. Such communication may occur between
processes that are executing on the same computer or between processes that
are executing on different computer systems tied together by a computer
network. Communications may be implemented via shared memory, in which
two or more processes read and write to a shared section of memory, or
message passing, in which packets of information in predefined formats are
moved between processes by the operating system.
Operating system services Error detection
- The operating system needs to detect and correct errors constantly. Errors may
occur in the CPU and memory hardware (such as a memory error or a power
failure), in I/O devices (such as a parity error on disk, a connection failure on a
network, or lack of paper in the printer), and in the user program (such as an
arithmetic overflow, an attempt to access an illegal memory location, or a too-
great use of CPU time). Correction might involve halting the system or
terminating a process
Operating system services Resource allocation
- When there are multiple users or multiple jobs running at the same time,
resources must be allocated to each of them. The operating system manages
many different types of resources. Some (such as CPU cycles, main memory, and
file storage) may have special allocation code, whereas others (such as I/O
devices) may have much more general request and release code
Operating system services Accounting
- We want to keep track of which users use how much and what kinds of
computer resources.
Operating system services: Protection and security.
- The owners of information stored in a multiuser or networked computer system
may want to control use of that information. When several separate processes
execute concurrently, it should not be possible for one process to interfere with
the others or with the operating system itself. Protection involves ensuring that
all access to system resources is controlled. Security involves securing the
system from outsiders, i.e. requiring users to authenticate themselves.
User Interface – command
interpreter
- CLI or command interpreter allows direct command entry.
- Sometimes implemented in kernel, sometimes by systems
program - Sometimes multiple types implemented as shells
- Primarily fetches a command from user and executes it
- Sometimes commands built-in, sometimes just names of
programs - Can use shell scripting to produce useful OS programs (Batch
Files)
User Interface – batch files
Collections of CLI commands run together to do
various tasks
User Interface – GUI
- Graphical User Interface (GUI)
- 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)
Program Execution and System
Calls
- 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) - Programming interface to the services provided by the OS
- Typically written in a high-level language
- 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)
What actually happens when a System
Program Makes a System Call?
- Typically the OS associates a number 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 the OS
kernel and returns status of the system call and any return values - The caller needs 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) - Parameters passing
- Use registers, table/memory block or the stack
Types of System Calls
- Process control
- File management
- Device management
- Information maintenance
- Communications
Types of System Calls Process control
- create process, terminate process, end, abort, load, execute, etc
Types of System Calls File management
- create file, delete file, open, close file, etc
Types of System Calls Device management
- request device, release device, read, write, etc
Types of System Calls Information maintenance
get time or date, set time or date, get system data, set system data,
etc
Types of System Calls Communications
create, delete communication connection, send & receive message
System programs
- Also known as system utilities. Basically, they provide a convenient
environment for program development and execution. - Some of them are simply user interfaces to system calls.
- Other are more complex, e.g. device driver
System programs categories
- Also known as system utilities. Basically, they provide a convenient
environment for program development and execution. - Some of them are simply user interfaces to system calls.
- Other are more complex, e.g. device driver
System programs categories
File management.
Status information.
File modification
Programming-language support.
Program loading and execution
Communications
Background services.
System programs categories File management
- These programs create, delete, copy, rename, print, dump, list, and generally manipulate files and
directories.
System programs categories Status information
- Some programs simply ask the system for the date, time, amount of available memory or disk
space, number of users, or similar status information. Others are more complex, providing
detailed performance, logging, and debugging information
System programs categories File modification
- Text editors and file content search/text transformations, et
System programs categories Communications
- These programs provide the mechanism for creating virtual connections among processes, users,
and computer systems. They allow users to send messages to one another’s screens, to browse
Web pages, to send e-mail messages, to log in remotely, or to transfer files from one machine to
another.
System programs categories Program loading and execution
- Once a program is assembled or compiled, it must be loaded into memory to be executed…
loaders, linkers, debuggers, etc
System programs categories Programming-language support
Compilers, assemblers, debuggers, and interpreters for common programming languages (such as
C, C++, Java, and PERL)
System programs categories Background services
- All general-purpose systems have methods for launching certain system-program processes at
boot time. Some of these processes terminate after completing their tasks, while others continue
to run until the system is halted. Constantly running system-program processes are known as
services, subsystems, or daemons. Include schedulers, system monitors, printer servers, et
Process management overview
- A process is essentially a program while being executed.
- It needs certain resources (i.e. CPU time, memory, files, and I/O devices)
to accomplish its task. These resources are allocated to the process
either when it is created or while it is executing. - It is the unit of work in most systems. Systems consist of a collection of
processes i.e. operating-system processes execute system code, and
user processes execute user code. All these processes may execute
concurrently. - Traditionally a process contained only a single thread of control as it ran.
Now, most modern operating systems support processes that have
multiple threads. - The operating system is responsible for several important aspects of
process and thread management, such as: - The creation and deletion of both user and system processes;
- The scheduling of processes; and
- The provision of mechanisms for synchronisation, communication, and
deadlock handling
- What is a process?
Jobs, user programs, operating system programs, tasks,
unit of work, etc.
What is a Process made of?
Text
Stack
Data
Heap
What is a Process made of? Text
- Program code + current activity status
(value of the program counter and
processors’ (CPU, etc.) registers
What is a Process made of?Stack
- Temporary data (such as function
parameters, return addresses, local
variables, etc.)
What is a Process made of?Data
- Global variables
What is a Process made of?* Heap
- Memory is dynamically allocated during
process run time - 0… Max denote memory allocated for the
process
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 (such as an
I/O completion or reception of a signal) - Ready. The process is waiting to be assigned to a processor
- Terminated. The process has finished execution
(These names are arbitrary, and they vary across operating systems) - Only one process can be Running at any time
- Many processes can be Ready and Waiting
Process Control Block
Process state (New, ready, running, waiting, etc.)
Program counter (The counter indicates the address of the next
instruction to be executed for this process)
CPU registers (The registers vary in number and type, depending
on the computer architecture. They include accumulators, index
registers, stack pointers, and general-purpose registers, plus any
condition-code information)
CPU-scheduling information (This information includes process
priority, pointers to scheduling queues, and any other scheduling
parameters)
Memory-management information (This information may
include such items as the value of the base and limit registers and
the page tables, or the segment tables, depending on the memory
system used by the operating system)
Accounting information (This information includes the amount of
CPU and real time used, time limits, account numbers, job or process
numbers, and so on)
I/O status information (This information includes the list of I/O
devices allocated to the process, a list of open files, and so on)
Process Scheduling
- The process scheduler is responsible for choosing and running processes
- When a process is allocated, the CPU it executes for a while and eventually
quits, is interrupted, or waits for the occurrence of a particular event, such
as the completion of an I/O request. - The process scheduler needs a job queue, a ready queue, a device queue
and others (we will worry about the first three) - Job queue
- Consists of all processes in the system.
- Ready queue
- Processes that are residing in main memory and are ready and waiting to
execute - Device queue
- A process wishes to make an I/O request to a shared device (e.g. disk, screen,
keyboard, printer, drone, killer penguin, etc.) The device might be busy dealing
with another process’ I/O request. - A device queue is therefore the list of processes waiting to use that device.
- Queues are generally stored as a linked list
- E.g. a ready-queue header contains pointers to the first and final PCBs in the
list. Each PCB includes a pointer field that points to the next PCB in the ready
queue.
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)