0% found this document useful (0 votes)
10 views7 pages

Understanding System Calls in OS

Uploaded by

Sharlin Lins L
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

Understanding System Calls in OS

Uploaded by

Sharlin Lins L
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

1.13 SYSTEM CALLS


• System calls provide a means for user or application programs to call upon the services of
the operating system.
• Generally written in C or C++, although some are written in assembly for optimal
performance.
Definition
The interface between a process and an operating system is provided by system calls. In
general, system calls are available as assembly language instructions. To call upon the services
of the operating system we use system calls.

Example of how system calls are used.


• You can use "strace" to see more examples of the large number of system calls invoked by
a single simple command.
• The API then makes the appropriate system calls through the system call interface, using a
table lookup to access specific numbered system calls, as shown in figure

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

The handling of a user application invoking the open( ) system call

• Parameters are generally passed to system calls via registers, or less commonly, by values
pushed onto the stack. Large blocks of data are generally accessed indirectly, through a
memory address passed in a register or on the stack, as shown in Figure

Passing of parameters as a table

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

Types of System Calls


There are six major categories
1. Process Control:
• Process control system calls include end, abort, load, execute, create process, terminate
process, get/set process attributes, wait for time or event, signal event, and allocate and free
memory.
• Processes must be created, launched, monitored, paused, resumed,and eventually
stopped.
• When one process pauses or stops, then another must be launched or resumed
• When processes stop abnormally it may be necessary to provide core dumps and/or other
diagnostic or recovery tools.
2. File Management
• File management system calls include create file, delete file, open, close, read, write,
reposition, get file attributes, and set file attributes.
• These operations may also be supported for directories as well as ordinary files.
3. Device Management
• Device management system calls include request device, release device, read, write,
reposition, get/set device attributes, and logically attach or detach devices.
• Devices may be physical (e.g. disk drives ), or virtual / abstract ( e.g. files, partitions, and
RAM disks ).
• Some systems represent devices as special files in the file system, so that accessing the
"file" calls upon the appropriate device drivers in the OS. See for example the /dev directory
on any UNIX system.
4. Information Maintenance
• Information maintenance system calls include calls to get/set the time, date, system data,
and process, file, or device attributes.
• Systems may also provide the ability to dump memory at any time, single step programs
pausing execution after each instruction, and tracing the operation of programs, all of which
can help to debug programs.

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

5. Communication
• Communication system calls create/delete communication connection, send/receive
messages, transfer status information, and attach/detach remote devices.
• The message passing model must support calls to:
• Identify a remote process and/or host with which to communicate.
• Establish a connection between the two processes.
• Open and close the connection as needed.
• Transmit messages along the connection.
• Wait for incoming messages, in either a blocking or non-blocking state.
• Delete the connection when no longer needed.
• The shared memory model must support calls to:
• Create and access memory that is shared amongst processes ( and threads. )
• Provide locking mechanisms restricting simultaneous access.
• Free up shared memory and/or dynamically allocate it as needed.
• Message passing is simpler and easier, ( particularly for inter-computer communications ),
and is generally appropriate for small amounts of data.
• Shared memory is faster, and is generally the better approach where large amounts
of data are to be shared, ( particularly when most processes are reading the data rather than
writing it, or at least when only one or a small number of processes need to change any given
data item. )

6. Protection
• Protection provides mechanisms for controlling which users / processes have access to
which system resources.
• System calls allow the access mechanisms to be adjusted as needed, and for non- privileged
users to be granted elevated access permissions under carefully controlled temporary
circumstances.
• Once only of concern on multi-user systems, protection is now important on all systems,
in the age of ubiquitous network connectivity.

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

1.14 SYSTEM PROGRAMS


• System programs provide OS functionality through separate applications, which are not
part of the kernel or command interpreters.
• They are also known as system utilities or system applications.
• Most systems also ship with useful applications such as calculators and simple editors, (
e.g. Notepad ). Some debate arises as to the border between system and non-system
applications.
System programs may be divided into these categories:
1. File management - programs to create, delete, copy, rename, print, list, and
generally manipulate files and directories.
2. Status information - Utilities to check on the date, time, number of users, processes
running, data logging, etc. System registries are used to store and recall
configuration information for particular applications.
3. File modification - e.g. text editors and other tools which can change file contents.
4. Programming-language support - E.g. Compilers, linkers, debuggers, profilers,
assemblers, library archive management, interpreters for common languages, and
support for make.
5. Program loading and execution - loaders, dynamic loaders, overlay loaders, etc., as
well as interactive debuggers.
6. Communications - Programs for providing connectivity between processes and
users, including mail, web browsers, remote logins, file transfers, and remote
command execution.
7. Background services - System daemons are commonly started when the system is
booted and run for as long as the system is running, handling necessary services.
Examples include network daemons, print servers, process schedulers, and system
error monitoring services.

1.15 OPERATING-SYSTEM GENERATION


OS may be designed and built for a specific HW configuration at a specific site, but
more commonly they are designed with a number of variable parameters and components,
which are then configured for a particular operating environment.

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

• Systems sometimes need to be re-configured after the initial installation, to add additional
resources, capabilities, or to tune performance, logging, or security.
Information that is needed to configure an OS include:
• What CPU(s) are installed on the system, and what optional characteristics does each have?
• How much RAM is installed? ( This may be determined automatically, either at install or
boot time. )
• What devices are present? The OS needs to determine which device drivers to include,
as well as some device-specific characteristics and parameters.
• What OS options are desired, and what values to set for particular OS parameters.
The latter may include the size of the open file table, the number of buffers to use, process
scheduling (priority) parameters, disk scheduling algorithms, number of slots in the process
table, etc.
2 Options
• At one extreme the OS source code can be edited, re-compiled, and linked into a new
kernel.
• At the other extreme a system configuration may be entirely defined by table data, in which
case the "rebuilding" of the system merely requires editing data tables.
• Once a system has been regenerated, it is usually required to reboot the system to activate
the new kernel. Because there are possibilities for errors, most systems provide some
mechanism for booting to older or alternate kernels.

1.16 System Boot


The procedure of starting a computer by loading the kernel is known as booting the system.
 A small piece of code known as the bootstrap program or bootstrap loader locates the
kernel, loads it into main memory, and starts its execution.
 First a simple bootstrap loader fetches a more complex boot program from disk
 A complex boot program loads the OS
 The bootstrap program can perform a variety of tasks. Usually, one task is to run
diagnostics to determine the state of the machine.
 It can also initialize all aspects of the system, from CPU registers to device controllers
and the contents of main memory and then it starts the Operating system.

CS8493-OPERATING SYSTEMS
ROHINI COLLEGE OF ENGINEERING & TECHNOLOGY

 All forms of ROM are also known as firmware, since their characteristics fall
somewhere between those of hardware and those of software.
 A problem with firmware in general is that executing code there is slower than
executing code in RAM.
 Some systems store the operating system in firmware and copy it to RAM for fast
execution.
 A final issue with firmware is that it is relatively expensive, so usually only small
amounts are available.
 For large operating systems the bootstrap loader is stored in firmware, and the
operating system is on disk.
 The Bootstrap program has a piece of code that can read a single block at a fixed
location from disk into memory and execute the code from that Boot block.
 The program stored in the boot block may be sophisticated enough to load the entire
operating system into memory and begin its execution.
 A disk that has a Boot partition is called as a Boot Disk.
 GRUB is an example of an open-source bootstrap program for Linux systems.

CS8493-OPERATING SYSTEMS

Common questions

Powered by AI

The six major categories of system calls are: 1) Process Control: Includes creating, executing, and terminating processes, managing process attributes, and memory allocation. 2) File Management: Involves tasks like creating, deleting, opening, closing, reading, and writing files. 3) Device Management: Pertains to operations such as reading, writing, and moving device data, as well as managing device connections. 4) Information Maintenance: Covers retrieving and updating system/session data, and program debugging. 5) Communication: Offers mechanisms for inter-process communication through communication connections and message passing. 6) Protection: Controls access to system resources and manages user permissions .

The bootstrap loader is a critical component in the system boot process; it initializes the system by loading the operating system kernel into main memory from a bootable disk and starting its execution. It begins with running diagnostics and initializing hardware components, ensuring all subsystems are ready before the comprehensive OS load begins. This mechanism supports the transition from firmware execution to full system operation .

System programs provide functionality to applications through separate user-level utilities or applications and are not integral to the kernel, unlike system calls which offer APIs for lower-level task execution directly interacting with the OS. System programs include file management tools, status utilities, file modification utilities, and so on, whereas system calls.allow programs to perform OS-level operations like process creation and management, file manipulation, and device communication .

Adjusting system protection mechanisms via system calls is necessary in scenarios requiring strict control over resource access and security, such as multi-user environments where resource allocation must be well-managed. In these cases, system calls ensure users can only access authorized data or devices, control system privileges, and can temporarily elevate permissions safely, which is crucial in ensuring data integrity in networked or sensitive computing systems .

System calls provide an interface for user-level applications to request services from the operating system. They act as a communication bridge, allowing processes to execute tasks such as creating or terminating processes, managing files, and handling device management. Since system calls constitute the permissible actions that application software can perform on the system, ensuring secure and efficient control of hardware resources, they play a crucial role in the safe and structured execution of applications .

In inter-process communication, message passing involves creating channels through which messages are sent and received. This method is simpler, particularly for inter-computer communications, and is suited for small data transfer. The shared memory model allows processes to share a memory segment and is more efficient for large data volumes, especially when data read operations are more frequent than write operations. It requires mechanisms for locking access to prevent concurrent data modification, making it faster for processes within the same machine .

Storing an operating system in firmware can offer the advantage of ensuring a consistent and protected environment during boot-up, as the initial boot code is safe from disk failures or alterations. However, executing code from firmware tends to be slower than running it from RAM and is costly due to limited storage space. Therefore, only critical or initial boot instructions are typically stored in firmware, with the operating system loaded into RAM for full execution .

In the context of ubiquitous network connectivity, system call-based protection mechanisms are vital for controlling access to system resources and preventing unauthorized access, data breaches, and other security threats. These mechanisms ensure the system can adjust access permissions dynamically and securely handle connections and resource requests from numerous users and external systems, thus maintaining both local and network-level security .

After the bootstrap loader has executed, the operating system performs tasks such as running system diagnostics to assess hardware status, initializing system components like CPU registers and device controllers, and setting up the necessary environment to bring the system to an operational state. This includes loading essential system services and daemons and facilitating a transition to user-level processes ready for interaction .

Post-installation, an operating system can be reconfigured by altering variable parameters such as device drivers, memory capacity, or system preferences. This may involve editing configuration files or using system utilities to redefine parameters like process table slots, scheduling policies, and resource allocation settings, sometimes necessitating a reboot to implement these changes. This flexibility allows the system to adapt to new hardware and evolving user or application needs .

You might also like