- What are the key services of an operating system? - What are the main approaches that users, processes and other systems use to access operating system services? - What are system calls? - What are system programs?
to programs → OS manages resources and executes programs
to users
almost all OS have a UI:
command line interface - text commands in specific format
batch interface (systems can communicate, instructions written in a file and the file is executed)
graphical user interface - a window system and I/O devices
systems can have both CLI and GUI - (FreeBSD only has command line interface- therefore has less file size overall compared to the Ubuntu devices)
OS responsible for
loading program into memory
allocating memory
executing program
terminating program normally or abnormally (indicates error)
process may need I/O which may involve a file or an I/O device (screen)
OS lets users control I/O since users can’t control them directly
programs need to
read and write files to directories
create and delete
search
move
view file info
some OS can include permissions to allow or deny access
OS can manage process communication (processes wanting to share information) if they are on the same computer or they are executing on different computers on the same network
communications can be implemented using
shared memory → 2 or more processes can read and write to a shared section of memory
message passing → packets in predefined formats are moved between the processes and the OS
OS can detect and correct errors
errors can occur in
memory hardware - memory error or power failure
I/O devices - parity error on disk, connection failure in network, no paper in printer
user program - arithmetic overflow, access illegal memory location, too much CPU time
to correct the errors the OS can
halt the system
terminate the error causing process
return an error code to the process so the process can detect and self correct
can have multiple users / processes running concurrently and resources need to be allocated to all
can be special allocation code (CPU cycles, main memory) or general allocation code (I/O devices) which consider different factors when allocating
e.g. CPU-scheduling routine which considers CPU speed, number of registers etc.
can be routines to allocate peripheral devices like printers
track which user is active, what computer resources users access and use
useful if many users use the same machine
useful in cloud resources, accounting to bill users, gathering statistics
people who own information in multiuser/ networked systems want to control the information use
one process should not be able to interfere with the OS or other processes
protection = ensure all access to system resources is controlled + protection against external attacks (eg. DDOS)
security = protect the system from outsiders access via user authentication, defending I/O devices from invalid access attempt
command line interface (aka. command interpreter)
graphical user interface (GUI)
the command interpreter eg. windows CMD (CLI) exists on the UI and allows users to directly enter commands to be performed by OS
can be implemented in the kernel or via a special program
CLIs are also called shells
CLI function → get the user command, send it to OS and execute it e.g. manipulate files
commands be implemented in 2 ways
commands are built-in and the command interpreter goes to prewritten code and makes a system call
command interpreter identifies files or programs to run with the command name
can use shell scripting to produce useful OS programs called Batch Files
is a user-friendly desktop metaphor based interface
has mouse, keyboard, monitor
icons to represent files, programs and actions
various mouse actions over the objects in the interface can do actions (eg. provide info, options, execution function)
could also be touchscreen interface for phones with gestures
command line more efficient and more functionality, batch files can be created for efficiency
gui is user friendly
a request by a process made via an interface for a service to be performed by the kernel.
system calls provide an interface to the OS services
structured like functions with parameters and return values written in C and C++
for a program to execute the OS needs to
load program into memory (disk space)
run the program
manage input and output
terminate execution normally or abnormally (indicating error)
all these things can be managed with heavy use of system calls
the API is accessed via a run-time support library of code
specifies the set of functions that are available to the application programmer including the expected parameters and return values
the functions that the API invokes are what actually make the system calls
eg. java, writing to a file, needs to access a service that the system provides
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)
Java API for the Java virtual machine (JVM)
program portability → any system can compile and run the program as long as the same API is used
direct system calls are detailed and difficult to manage without an API
a set of functions structured as libraries (e.g. standard c library) included with the compiler which provides a system call interface.
different programming languages each have their own run-time support systems
the system call interface intercepts the API function calls and invokes the necessary system call for the operating system
the OS gives each system call a number and system call interface maintains a table containing the system calls and their number
SCI invokes the intended system call in the kernel and passes the needed parameters to the system call
SCI returns the system call status and any return values to API
doesn’t need to know HOW the system call is implemented as most OS interface are details are hidden by the API and are managed by the RTE
just needs to follow the API and understand what the OS will do as a result of the call
USER APP → API → SYSTEM CALL INTERFACE → KERNEL (containing OS services)
user application contains the API
API calls system call interface
system call interface can make system calls to the kernal and request OS services
OS can return the variables as needed back to system call interface and then to API
more information may be needed for the system call to function and not just the name of the system call
e.g.
memory length
source
file variables
pass these to the OS as parameters
the names of system calls can vary
different OS show different things/ act differently even with the same set of system calls (eg. macOS vs. Windows vs. Linux)
create() + terminate() process
load() + execute() process
get + set process attributes - e.g, job priority, can be used to controll a new process
wait + signal event - waits until execution done,, can wait certain amount of time or for signalled event
allocate + free memory - processes can lock data if it’s being shared to ensure data integrity
if terminated abnormally with error, process will memory dump and error message generated. memory dump is written to a log file and examined by a debugger - system program designed to find errors
when terminated, OS transfers control to the invoking command interpreter.
command line - command interpreter reads next command and the user can react
gui - error pop up displayed
batch system - terminate whole job and go to next one
sometimes there is special recovery when errors happen
error levels can be defined for error input
allows the command interpreter to execute a program as requested by user/ another program. loading a new program can be done in 2 ways:
if control returns to the existing process after the loaded one has finished then memory needs to be stored about the existing one
if the 2 process can run concurrently then a new process must be multiprogrammed
create() + delete() file - system calls the file name or file attribute
open() + close() file
read() + write() + reposition() file
get() + set() file attributes - including name, size
these functions can be used to organise directories in directory structure
other systems have move() and copy() functions
processes need resources (called devices) to execute e.g., main memory, disk drives, can be physical or virtual. if available resources are allocated but if not available the process waits
request() + release() (to free up) device
read() + write() + reposition() device
get() + set device attributes
logically attach or detach devices
if 2 processes want to access the same device (monitor, keyboard) a system call will request this service and the OS will schedule time for the I/O device
some systems merge the system calls for device management and file management as they’re similar
exist to transfer information between user and os
get + set date or time
get + set system data (number of users)
dump() memory for debugging
provides time profile - time that program executes at a certain location, done using tracing facility or regular timer inturrupts
get() + set() process attributes
important for synchronising everything (including stuff mentioned above)
eg. want to access internet wont work with wrong date and time
2 models of interprocess communication -
message-parsing model - processes communicate by sending messages which can be passed directly or indirectly through a common mail box. better for small messages as conflicts avoided and easy to implement
shared memory model - processes both access regions of memory to communicate
both use different system calls
create() + delete() communication connection - must be opened for communication to happen and name of other communicator must be known (by host name/ IP address/ process name. using get_hostid()
accept_connection()
daemon - special system program that wait for connection, one for client and server using waitforconnection()
send + receive messages()
sharedmemorycreate() - sharedmemoryattatch() to access regions of memory
can read() and write() to same area but not write to same location simultaneously
for protecting the access of resources provided by os
get() + setfilepermissions()
system programs to provide a user interface to system calls
complex system programs eg. device drivers
defined by the system programs and the application programs and not the system calls.
user can have different view depending on type of UI (gui, command, batch) but the system calls that function are the same
programs that generally access and manipulate files and directories
create
delete
copy
rename
list
programs that request, format and print information. e.g. to the terminal/ output device/ file/ display in the GUI window
simple versions - programs that request the date, time, amount of available memory, disk space, or other status information
complex version - request detailed performance info, logging and debugging information
can also support a registry which is used to store and retrieve configuration information
programs such as text editors that can create and modify file contents stored on a disk or other device
can contain special commands to search file content or perform text transformations
Compilers, assemblers, debuggers, and interpreters for common programming languages (such as C, C++, Java, and PERL)
could be included in an OS or download separately
Once a program is assembled or compiled, it must be loaded into memory to be executed
can provide loaders, linkers, debuggers, etc.
programs that provide the mechanism for creating virtual connections between processes, users, and computer systems
allow users to send messages to one another’s screens, browse Web pages, send e-mail messages, log in remotely, or to transfer files from one machine to another.
don’t see them running but if we inspect the process that are running we can see them
includes methods to launch system-program processes at boot time
background services can terminate after a task finishes or continue to run until system is halted
includes daemons
services/ subsystems/ daemons - system programs that are constantly running, eg. network daemon, process schedulers, print servers.
a system can have multiple daemons.
the system needs to listen to network connections to connect requests to correct daemon.
daemons can also run important activities in the user context instead of the kernel