SlideShare a Scribd company logo
Operating System
Operating System Services
• These operating-system services are provided
for the convenience of the programmer, to
make the programming task easier
• Common services of OS are
– User interface
– Program execution
– I/O operations
– File-system manipulation
– Communications
Operating System Services
– Error detection
– Resource allocation
– Accounting
– Protection and security
A view of operating system services
Operating System Services
 User interface. Almost all operating systems have a user interface (UI).
• One is a command-line interface (CLI),
• Batch interface
• Graphical user interface (GUI)
 Program execution. The system must be able to load a program into
memory and to run that program.
 I/O operations. A running program may require I/O, which may involve a file
or an I/O device. For specific devices, special functions may be desired
 File-system manipulation. The file system is of particular interest.
Obviously, 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.
Operating System Services
• One set of operating-system services provides
functions that are helpful to the user
– 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 are exchanged by the OS)
– 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 & consistent computing and safeguarding system
• Debugging facilities can greatly enhance the user’s and programmer’s
abilities to find errors and efficiently use the system
Operating System Services
• A set of OS functions (in the form of system calls) exists for ensuring the
efficient operation of the system itself by managing and sharing various
system resources
– Resource allocation - Multiple users or multiple jobs, running concurrently,
need resources. These must be allocated to them carefully
• Many types of resources (e.g. CPU cycles, main memory, file storage, etc) may
have special allocation code (shared) , others (such as I/O devices like printer,
tapes, etc.) may have general request and release code (exclusive).
– Accounting - To keep track of which user uses how much and what kinds of
computer resources
– Protection and security - The owners of information stored in a multi-user
or networked computer system may want to secure use of that information.
Concurrent processes should not interfere adversely with each other
• Protection involves ensuring that all access to system resources is controlled
• Security of the system from each other/outsiders requires user authentication,
extends to defending external I/O devices from invalid access attempts
Command Interpreters
• Some operating systems include the command
interpreter in the kernel
• On systems with multiple command
interpreters to choose from, the interpreters
are known as shells.
User Interface :- CLI
Command Line Interface (CLI) provides a user
interface and interact using direct command entry
on console
• Sometimes implemented in kernel, sometimes as systems
programs (non resident)
• Sometimes multiple flavors are implemented – shells (Bourne
shell, C shell, etc.)
• Primarily takes a command from user and executes it
– Sometimes built-in commands, sometimes just names of programs,
in the latter case, adding new features doesn’t require shell
modification
• CLI based Utilities (shell programs)
User Interface :- GUI
• User-friendly desktop metaphor interface
– Usually mouse, keyboard, and monitor for I/O
– Icons represent files, programs, actions, etc.
– Various mouse buttons over objects in the interface cause various
actions (provide information, options, execute function, open directory
(or 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 as “Aqua” GUI interface with UNIX kernel underneath
and shells available
– Solaris/Linux are CLI with optional GUI interfaces (Java Desktop, KDE,
etc.)
System Calls
• System calls provide an interface to the
services made available by an operating
system
• These calls are generally available as routines
written in C and C++, although certain low-
level tasks may have to be written using
assembly-language instructions
Application Programming Interface
• Frequently, systems execute thousands of system
calls per second
Three of the most common APIs available to
application programmers are
Windows API for Windows systems,
POSIX API for POSIX-based systems (which include virtually
all versions of UNIX, Linux, and Mac OSX),
Java API for programs that run on the Java virtual machine.
A programmer accesses an API via a library of code
provided by the operating system.
Example of how system calls are used.
• System call execution sequence to copy the
contents of one file to another file
Types of System Calls
The handling of a user application invoking
the open() system call
Types of System Calls
For interaction with system
• Process control
• File management
• Device management
• Information maintenance
• Communications
System Call APIs in a Linux Kernel
Each system call has a corresponding wrapper
routine, which defines the Application Program
Interface (API). An API does not necessarily
correspond to a specific system call.
Wrapper Routines: The system call interface
provided by some API, defined by the libc,
standard C library, refer to a routine, whose
purpose is to issue a system call, handling
In/Out parameters.
System Call – Execution in Kernel mode
• User-space applications cannot execute kernel code
directly, making a simple function call
• Kernel exists in a protected memory space.
• System security and stability could be jeopardized if
applications directly read and write to the kernel's address
space.
• User applications causes an exception or trap to enter the
kernel by switching to kernel mode, to execute system call
in kernel-space by the kernel on behalf of the application.
• The mechanism is a software interrupt: Incur an exception,
then the system switches to kernel mode and executes the
exception handler which is the system call handler.
System Call – Execution in Kernel mode
• Software interrupt on x86 is the int $0x80 instruction. Triggers
a switch to kernel mode and the execution of exception vector
128, the system call handler.
• The system call handler is the aptly named function:
system_call().
• SC is architecture dependent and typically implemented in
assembly
• Intel, x86 processors added a feature known as sysenter. This
feature provides a faster, more specialized way of trapping
into a kernel to execute a system call, than using the int
interrupt instruction. Support for this feature was quickly
added to the kernel.
System Call Implementation (Linux)
• Typically, a number is associated with each system call
– The syscall number is important; when assigned, it cannot
change
– System-call interface maintains a table indexed according
to these numbers
– the syscall number is fed to the kernel via the 32 bit
register eax, the number corresponding to the desired
system call, before causing the trap into the kernel.
– The parameters are stored in registers. On x86, the 32 bit
registers ebx, ecx, edx, esi, and edi contain, the first five
arguments.
System Call Implementation (Linux)
• Most details of OS interface are hidden from programmer by
API
– Managed by run-time support or object code library (set of
functions built into libraries, included with compiler)
– The caller need not know, how the system call is
implemented. Just needs to obey API and understand what
OS will do as a result call
– System calls in Linux are faster, because of Linux's
incredibly fast context switch times (entering and exiting
the kernel is a streamlined) and secondly the simplicity of
the system call handler.
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 desired
system call
• Three general methods are used to pass parameters to the OS
(System Call)
– Simplest: pass the parameters in registers
• In some cases, may be more parameters than available registers
– Parameters stored in a block, or table, in memory, and address of block passed
as a parameter in a register
• This approach is taken by Linux and Solaris
– Parameters placed, or pushed, onto the (Kernel) 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
Parameter Passing via Table
• if a system call is removed, its system call
number cannot be reused (recycled), otherwise
previous compiled code would invoke the system
call will in reality call another.
• Linux provides a "not implemented" system call,
sys_ni_syscall(), which does nothing except
return -ENOSYS. This is used to "plug the hole" in
the rare event, if a syscall is removed or
otherwise made unavailable.
Parameter Passing via Table
MS-DOS execution
(a) At system startup (b) Running a Single
stream of execution. Further streams of
execution, possible by Terminate Stay
Resident (TSRs), associated with some
interrupt.
System Programs
(For low level interaction with system)
• System programs provide a convenient environment for using
system, program development and execution. They can be divided
into:
– File manipulation
– Status information
– File modification
– Programming language support
– Program loading and execution
– Communications
– Application programs
• Provision of tools for distributed processing on networked systems
• Most users’ view of the operating system is defined by system
programs, not by the actual system calls
System Programs
• Provide a convenient environment for close level interaction with
system[s].
– Some of them are simply user interfaces to system calls; others are
considerably more complex
• File management - Create, delete, copy, rename, print, dump, list,
and generally manipulate files and directories
• 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
System Programs (cont’d)
• 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 are sometimes provided
• Program loading and execution- Absolute loaders, re-
locatable loaders, linkage editors, and overlay-loaders,
debugging systems for higher-level and machine
language
System Programs (cont’d)
• 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 tasks/files from one machine to another

More Related Content

PDF
Ch2 operating-system structures
PDF
Operating System Structure Part-I.pdf
PPT
operating system introduction and organization
PPTX
PPTX
Design Of Operating System_Lecture_OS_2.pptx
PDF
02_os_structures.pdfbnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
PPT
Introduction to System Calls
PPT
System calls in Linux environment for beginners
Ch2 operating-system structures
Operating System Structure Part-I.pdf
operating system introduction and organization
Design Of Operating System_Lecture_OS_2.pptx
02_os_structures.pdfbnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Introduction to System Calls
System calls in Linux environment for beginners

Similar to Advanced Bulkification Strategies in Apex Triggers (20)

PPTX
chapter2.pptx
PPTX
Operating System Module 1 Session 6.pptx
PPTX
Services and system calls
PPTX
Chapter No 2 Services and Components of Operating System.pptx
PPT
OS Services, System call, Virtual Machine
PPTX
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
PPTX
Chapter 1 - Operating Systems Introduction.pptx
PDF
2 operating system structures
PPT
Operating System 2
PPTX
Operating system 11 system calls
PDF
Unit 4
PPT
PPTX
MODULE-1_Operating System Services - ppt
PPT
OS - Ch2
PPT
Chapter 2 - Operating System Structures
PPT
Operating-System Structures
PPTX
operating system calls input and output by (rohit malav)
PPT
ch2_OS Structures.ppt To discuss the various ways of structuring an operatin...
PDF
osunit1ppt-23011904470yuoij4-685c22ef.pdf
PPTX
OS UNIT 1 PPT.pptx
chapter2.pptx
Operating System Module 1 Session 6.pptx
Services and system calls
Chapter No 2 Services and Components of Operating System.pptx
OS Services, System call, Virtual Machine
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
Chapter 1 - Operating Systems Introduction.pptx
2 operating system structures
Operating System 2
Operating system 11 system calls
Unit 4
MODULE-1_Operating System Services - ppt
OS - Ch2
Chapter 2 - Operating System Structures
Operating-System Structures
operating system calls input and output by (rohit malav)
ch2_OS Structures.ppt To discuss the various ways of structuring an operatin...
osunit1ppt-23011904470yuoij4-685c22ef.pdf
OS UNIT 1 PPT.pptx
Ad

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
additive manufacturing of ss316l using mig welding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Geodesy 1.pptx...............................................
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
composite construction of structures.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Construction Project Organization Group 2.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
additive manufacturing of ss316l using mig welding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Geodesy 1.pptx...............................................
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Internet of Things (IOT) - A guide to understanding
OOP with Java - Java Introduction (Basics)
Foundation to blockchain - A guide to Blockchain Tech
Model Code of Practice - Construction Work - 21102022 .pdf
Operating System & Kernel Study Guide-1 - converted.pdf
composite construction of structures.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Ad

Advanced Bulkification Strategies in Apex Triggers

  • 2. Operating System Services • These operating-system services are provided for the convenience of the programmer, to make the programming task easier • Common services of OS are – User interface – Program execution – I/O operations – File-system manipulation – Communications
  • 3. Operating System Services – Error detection – Resource allocation – Accounting – Protection and security
  • 4. A view of operating system services
  • 5. Operating System Services  User interface. Almost all operating systems have a user interface (UI). • One is a command-line interface (CLI), • Batch interface • Graphical user interface (GUI)  Program execution. The system must be able to load a program into memory and to run that program.  I/O operations. A running program may require I/O, which may involve a file or an I/O device. For specific devices, special functions may be desired  File-system manipulation. The file system is of particular interest. Obviously, 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.
  • 6. Operating System Services • One set of operating-system services provides functions that are helpful to the user – 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 are exchanged by the OS) – 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 & consistent computing and safeguarding system • Debugging facilities can greatly enhance the user’s and programmer’s abilities to find errors and efficiently use the system
  • 7. Operating System Services • A set of OS functions (in the form of system calls) exists for ensuring the efficient operation of the system itself by managing and sharing various system resources – Resource allocation - Multiple users or multiple jobs, running concurrently, need resources. These must be allocated to them carefully • Many types of resources (e.g. CPU cycles, main memory, file storage, etc) may have special allocation code (shared) , others (such as I/O devices like printer, tapes, etc.) may have general request and release code (exclusive). – Accounting - To keep track of which user uses how much and what kinds of computer resources – Protection and security - The owners of information stored in a multi-user or networked computer system may want to secure use of that information. Concurrent processes should not interfere adversely with each other • Protection involves ensuring that all access to system resources is controlled • Security of the system from each other/outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts
  • 8. Command Interpreters • Some operating systems include the command interpreter in the kernel • On systems with multiple command interpreters to choose from, the interpreters are known as shells.
  • 9. User Interface :- CLI Command Line Interface (CLI) provides a user interface and interact using direct command entry on console • Sometimes implemented in kernel, sometimes as systems programs (non resident) • Sometimes multiple flavors are implemented – shells (Bourne shell, C shell, etc.) • Primarily takes a command from user and executes it – Sometimes built-in commands, sometimes just names of programs, in the latter case, adding new features doesn’t require shell modification • CLI based Utilities (shell programs)
  • 10. User Interface :- GUI • User-friendly desktop metaphor interface – Usually mouse, keyboard, and monitor for I/O – Icons represent files, programs, actions, etc. – Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (or 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 as “Aqua” GUI interface with UNIX kernel underneath and shells available – Solaris/Linux are CLI with optional GUI interfaces (Java Desktop, KDE, etc.)
  • 11. System Calls • System calls provide an interface to the services made available by an operating system • These calls are generally available as routines written in C and C++, although certain low- level tasks may have to be written using assembly-language instructions
  • 12. Application Programming Interface • Frequently, systems execute thousands of system calls per second Three of the most common APIs available to application programmers are Windows API for Windows systems, POSIX API for POSIX-based systems (which include virtually all versions of UNIX, Linux, and Mac OSX), Java API for programs that run on the Java virtual machine. A programmer accesses an API via a library of code provided by the operating system.
  • 13. Example of how system calls are used. • System call execution sequence to copy the contents of one file to another file
  • 15. The handling of a user application invoking the open() system call
  • 16. Types of System Calls For interaction with system • Process control • File management • Device management • Information maintenance • Communications
  • 17. System Call APIs in a Linux Kernel Each system call has a corresponding wrapper routine, which defines the Application Program Interface (API). An API does not necessarily correspond to a specific system call. Wrapper Routines: The system call interface provided by some API, defined by the libc, standard C library, refer to a routine, whose purpose is to issue a system call, handling In/Out parameters.
  • 18. System Call – Execution in Kernel mode • User-space applications cannot execute kernel code directly, making a simple function call • Kernel exists in a protected memory space. • System security and stability could be jeopardized if applications directly read and write to the kernel's address space. • User applications causes an exception or trap to enter the kernel by switching to kernel mode, to execute system call in kernel-space by the kernel on behalf of the application. • The mechanism is a software interrupt: Incur an exception, then the system switches to kernel mode and executes the exception handler which is the system call handler.
  • 19. System Call – Execution in Kernel mode • Software interrupt on x86 is the int $0x80 instruction. Triggers a switch to kernel mode and the execution of exception vector 128, the system call handler. • The system call handler is the aptly named function: system_call(). • SC is architecture dependent and typically implemented in assembly • Intel, x86 processors added a feature known as sysenter. This feature provides a faster, more specialized way of trapping into a kernel to execute a system call, than using the int interrupt instruction. Support for this feature was quickly added to the kernel.
  • 20. System Call Implementation (Linux) • Typically, a number is associated with each system call – The syscall number is important; when assigned, it cannot change – System-call interface maintains a table indexed according to these numbers – the syscall number is fed to the kernel via the 32 bit register eax, the number corresponding to the desired system call, before causing the trap into the kernel. – The parameters are stored in registers. On x86, the 32 bit registers ebx, ecx, edx, esi, and edi contain, the first five arguments.
  • 21. System Call Implementation (Linux) • Most details of OS interface are hidden from programmer by API – Managed by run-time support or object code library (set of functions built into libraries, included with compiler) – The caller need not know, how the system call is implemented. Just needs to obey API and understand what OS will do as a result call – System calls in Linux are faster, because of Linux's incredibly fast context switch times (entering and exiting the kernel is a streamlined) and secondly the simplicity of the system call handler.
  • 22. 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 desired system call • Three general methods are used to pass parameters to the OS (System Call) – Simplest: pass the parameters in registers • In some cases, may be more parameters than available registers – Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register • This approach is taken by Linux and Solaris – Parameters placed, or pushed, onto the (Kernel) 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
  • 23. Parameter Passing via Table • if a system call is removed, its system call number cannot be reused (recycled), otherwise previous compiled code would invoke the system call will in reality call another. • Linux provides a "not implemented" system call, sys_ni_syscall(), which does nothing except return -ENOSYS. This is used to "plug the hole" in the rare event, if a syscall is removed or otherwise made unavailable.
  • 25. MS-DOS execution (a) At system startup (b) Running a Single stream of execution. Further streams of execution, possible by Terminate Stay Resident (TSRs), associated with some interrupt.
  • 26. System Programs (For low level interaction with system) • System programs provide a convenient environment for using system, program development and execution. They can be divided into: – File manipulation – Status information – File modification – Programming language support – Program loading and execution – Communications – Application programs • Provision of tools for distributed processing on networked systems • Most users’ view of the operating system is defined by system programs, not by the actual system calls
  • 27. System Programs • Provide a convenient environment for close level interaction with system[s]. – Some of them are simply user interfaces to system calls; others are considerably more complex • File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories • 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
  • 28. System Programs (cont’d) • 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 are sometimes provided • Program loading and execution- Absolute loaders, re- locatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language
  • 29. System Programs (cont’d) • 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 tasks/files from one machine to another

Editor's Notes

  • #5: • User interface. Almost all operating systems have a user interface (UI).This interface can take several forms. One is a command-line interface (CLI), which uses text commands and a method for entering them (say, a program to allow entering and editing of commands). Another is a batch interface, in which commands and directives to control those commands are entered into files, and those files are executed. Most commonly a graphical user interface (GUI) is used. Here, the interface is a window system with a pointing device to direct I/O, choose from menus, and make selections and a keyboard to enter text. Some systems provide two or all three of these variations. • 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). • I/O operations. A running program may require I/O, which may involve a file or an I/O device. For specific devices, special functions may be desired (such as recording to a CD or DVD drive or blanking a CRT screen). For efficiency and protection, users usually cannot control I/O devices directly. Therefore, the operating system must provide a means to do I/O. • File-system manipulation. The file system is of particular interest. Obviously, 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 programs include permissions management to allow or deny access to files or directories based on file ownership. • 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.
  • #6: 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 or through message passing, in which packets of information are moved between processes by the operating system. • Error detection. The operating system needs to be constantly aware of possible errors. 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 tape, 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). For each type of error, the operating system should take the appropriate action to ensure correct and consistent computing. Debugging facilities can greatly enhance the user's and programmer's abilities to use the system efficiently.
  • #7: Resource allocation. When there are multiple users or multiple jobs running at the same time, resources must be allocated to each of {hem. Many different types of resources are managed by the operating system. 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. For instance, in determining how best to use the CPU, operating systems have CPU-scheduling routines that take into account the speed of the CPU, the jobs that must be executed, the number of registers available, and other factors. There may also be routines to allocate printers, modems, USB storage drives, and other peripheral devices. Accounting. We want to keep track of which users use how much and what kinds of computer resources. This record keeping may be used for accounting (so that users can be billed) or simply for accumulating usage statistics. Usage statistics may be a valuable tool for researchers who wish to reconfigiire the system to improve computing 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 of the system from outsiders is also important. Such security starts with requiring each user to authenticate himself or herself to the system, usually by means of a password, to gain access to system resources. It extends to defending external I/O devices, including modems and network adapters, from invalid access attempts and to recording all such connections for detection of break-ins. If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
  • #8: Some operating systems include the command interpreter in the kernel. Others, such asWindows and UNIX, treat the command interpreter as a special program that is running when a job is initiated or when a user first logs on (on interactive systems). On systems with multiple command interpreters to choose from, the interpreters are known as shells. For example, on UNIX and Linux systems, a user may choose among several different shells, including the Bourne shell, C shell, Bourne-Again shell, Korn shell, and others. Third-party shells and free user-written shells are also available. Most shells provide similar functionality,and a user’s choice of which shell to use is generally based on personal preference. The main function of the command interpreter is to get and execute the next user-specified command. Many of the commands given at this level manipulate files: create, delete, list, print, copy, execute, and so on. The MS-DOS and UNIX shells operate in this way. These commands can be implemented in two general ways. In one approach, the command interpreter itself contains the code to execute the command. For example, a command to delete a file may cause the command interpreter to jump to a section of its code that sets up the parameters and makes the appropriate system call. In this case, the number of commands that can be given determines the size of the command interpreter, since each command requires its own implementing code. An alternative approach—used by UNIX, among other operating systems implements most commands through system programs. In this case, the command interpreter does not understand the command in any way; it merely uses the command to identify a file to be loaded into memory and executed.
  • #11: System calls provide an interface to the services made available by an operating system. These calls are generally available as routines written in C and C++, although certain low-level tasks (for example, tasks where hardware must be accessed directly) may have to be written using assembly-language instructions. Before we discuss how an operating system makes system calls available, let’s first use an example to illustrate how system calls are used: writing a simple program to read data from one file and copy them to another file. The first input that the program will need is the names of the two files: the input file and the output file. These names can be specified in many ways, depending on the operating-system design. One approach is for the program to ask the user for the names. In an interactive system, this approach will require a sequence of system calls, first to write a prompting message on the screen and then to read from the keyboard the characters that define the two files. On mouse-based and icon-based systems, a menu of file names is usually displayed in a window. The user can then use the mouse to select the source name, and a window can be opened for the destination name to be specified. This sequence requires many I/O system calls. Once the two file names have been obtained, the program must open the input file and create the output file. Each of these operations requires another system call. Possible error conditions for each operation can require additional system calls. When the program tries to open the input file, for example, it may find that there is no file of that name or that the file is protected against access. In these cases, the program should print a message on the console (another sequence of system calls) and then terminate abnormally (another system call). If the input file exists, then we must create a new output file. We may find that there is already an output file with the same name. This situation may cause the program to abort (a system call), or we may delete the existing file (another system call) and create a new one (yet another system call). Another option, in an interactive system, is to ask the user (via a sequence of system calls to output the prompting message and to read the response from the terminal) whether to replace the existing file or to abort the program. When both files are set up, we enter a loop that reads from the input file (a system call) and writes to the output file (another system call). Each read and write must return status information regarding various possible error conditions. On input, the program may find that the end of the file has been reached or that there was a hardware failure in the read (such as a parity error). The write operation may encounter various errors, depending on the output device (for example, no more disk space). Finally, after the entire file is copied, the program may close both files (another system call), write a message to the console or window (more system calls), and finally terminate normally (the final system call). This system-call sequence is shown in Figure 2.5. As you can see, even simple programs may make heavy use of the operating system.
  • #12: Frequently, systems execute thousands of system calls per second. Most programmers never see this level of detail, however. Typically, application developers design programs according to an application programming interface (API). The API specifies a set of functions that are available to an application programmer, including the parameters that are passed to each function and the return values the programmer can expect. Three of the most common APIs available to application programmers are the Windows API for Windows systems, the POSIX API for POSIX-based systems (which include virtually all versions of UNIX, Linux, and Mac OSX), and the Java API for programs that run on the Java virtual machine. A programmer accesses an API via a library of code provided by the operating system. In the case of UNIX and Linux for programs written in the C language, the library is called libc. Note that—unless specified—the system-call names used throughout this text are generic examples. Each operating system has its own name for each system call. Behind the scenes, the functions that make up an API typically invoke the actual system calls on behalf of the application programmer. For example, the Windows function CreateProcess() (which unsurprisingly is used to create a new process) actually invokes the NTCreateProcess() system call in the Windows kernel.
  • #14: Why would an application programmer prefer programming according to an API rather than invoking actual system calls? There are several reasons for doing so. One benefit concerns program portability. An application programmer designing a program using an API can expect her program to compile and run on any system that supports the same API (although, in reality, architectural differences often make this more difficult than it may appear). Furthermore, actual system calls can often be more detailed and difficult to work with than the API available to an application programmer. Nevertheless, there often exists a strong correlation between a function in the API and its associated system call within the kernel. In fact, many of the POSIX and Windows APIs are similar to the native system calls provided by the UNIX, Linux, and Windows operating systems. For most programming languages, the run-time support system (a set of functions built into libraries included with a compiler) provides a system call interface that serves as the link to system calls made available by the operating system. The system-call interface intercepts function calls in the API and invokes the necessary system calls within the operating system. Typically, a number is associated with each system call, and the system-call interface maintains a table indexed according to these numbers. The system call interface then invokes the intended system call in the operating-system kernel and returns the status of the system call and any return values.
  • #16: 2.4.1 Process Control A running program needs to be able to halt its execution either normally (end) or abnormally (abort). If a system call is made to terminate the currently running program abnormally, or if the program runs into a problem and causes an error trap, a dump of memory is sometimes taken and an error message generated. The dump is written to disk and may be examined by a debugger—a system program designed to aid the programmer in finding and correcting bugs-—to determine the cause of the problem. • Process control o end, abort o load, execute o create process, terminate process o get process attributes, set process attributes o wait for time o wait event, signal event o allocate and free memory • File management ° create file, delete file o open, close ° read, write, reposition o get file attributes, set file attributes • Device management o request device, release device ° read, write, reposition o get device attributes, set device attributes ° logically attach or detach devices • Information maintenance o get time or date, set time or date o get system data, set system data o get process, file, or device attributes o set process, file, or device attributes • Communications 0 create, delete communication connection ° send, receive messages o transfer status information o attach or detach remote devices Figure 2.5 Types of system calls.
  • #24: Three general methods are used to pass parameters to the operating system. The simplest approach is to pass the parameters in registers. In some cases, however, there may be more parameters than registers. In these cases, the parameters are generally stored in a block, or table, in memory, and the address of the block is passed as a parameter in a register (Figure 2.7). This is the approach taken by Linux and Solaris. Parameters also can be placed, or pushed, onto the stack by the program and popped off the stack by the operating system. Some operating systems prefer the block or stack method because those approaches do not limit the number or length of parameters being passed.
  • #26: Another aspect of a modern system is its collection of system programs. Recall Figure 1.1, which depicted the logical computer hierarchy. At the lowest level is hardware. Next is the operating system, then the system programs, and finally the application programs. System programs, also known as system utilities, provide a convenient environment for program development and execution. Some of them are simply user interfaces to system calls. Others are considerably more complex.
  • #27: They can be divided into these categories: • File management. These programs create, delete, copy, rename, print, dump, list, and generally manipulate files and directories. • 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. Typically, these programs format and print the output to the terminal or other output devices or files or display it in a window of the GUI. Some systems also support a registry, which is used to store and retrieve configuration information.
  • #28: • File modification. Several text editors may be available to create and modify the content of files stored on disk or other storage devices. There may also be special commands to search contents of files or perform transformations of the text. • Programming-language support. Compilers, assemblers, debuggers, and interpreters for common programming languages (such as C, C++, Java, and PERL) are often provided with the operating system or available as a separate download. • Program loading and execution. Once a program is assembled or compiled, it must be loaded into memory to be executed. The system may provide absolute loaders, relocatable loaders, linkage editors, and overlay loaders. Debugging systems for either higher-level languages or machine language are needed as well.
  • #29: • 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. • 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. One example is the network daemon discussed in Section 2.4.5. In that example, a system needed a service to listen for network connections in order to connect those requests to the correct processes. Other examples include process schedulers that start processes according to a specified schedule, system error monitoring services, and print servers. Typical systems have dozens of daemons. In addition, operating systems that run important activities in user context rather than in kernel context may use daemons to run these activities. Along with system programs, most operating systems are supplied with programs that are useful in solving common problems or performing common operations. Such application programs include Web browsers, word processors and text formatters, spreadsheets, database systems, compilers, plotting and statistical-analysis packages, and games. The view of the operating system seen by most users is defined by the application and system programs, rather than by the actual system calls. Consider a user’s PC. When a user’s computer is running the Mac OS X operating system, the user might see the GUI, featuring amouse-and-windows interface. Alternatively, or even in one of the windows, the user might have a command-line UNIX shell. Both use the same set of system calls, but the system calls look different and act in different ways. Further confusing the user view, consider the user dual-booting from Mac OS X into Windows. Now the same user on the same hardware has two entirely different interfaces and two sets of applications using the same physical resources. On the same hardware, then, a user can be exposed to multiple user interfaces sequentially or concurrently.