Chapter 2: Operating System Services (cont.)
Touch Screen Interface:
A touch screen interface is a type of computer display screen that allows the user to interact with the computer by touching the screen directly, instead of using a mouse or keyboard. This technology enables the user to perform actions such as tapping, swiping, and zooming by touching the screen with their fingers or a stylus.
Function Call vs Library Function Call vs System Call
Function Calls:
- A function call is an instruction in a program that invokes a specific function or subroutine to perform a certain task.
- A function call consists of the function name followed by a list of arguments in parentheses.
- The function executes the instructions within its body and returns control to the calling code once it is finished.
System Calls:
- System calls are a type of function call that provide an interface for a program to request services from the operating system.
- System calls allow the program to perform tasks such as accessing files, allocating memory, creating processes, and communicating with other programs.
Library Calls:
- Library calls are a type of function call that provide access to a library of pre-written functions.
- A library is a collection of functions and data that can be used by a program to perform various tasks.
- Library calls allow the programmer to make use of these pre-written functions without having to write the code themselves, making it easier to develop programs quickly and efficiently.
- Linking
- The linker is a software tool that combines object files and libraries generated by a compiler into a single executable program.
- It resolves symbolic references between functions and variables and adjusts memory addresses to create the final program
System Calls
- A request to the operating system to perform some activity
- These can be expensive
Steps in making a system call (See picture numbers and below)
-
1-3: PUSH parameter in stack
-
4-5: Library Call (puts syscall # in CPU register)
-
6: Switch to kernel mode (return address saved on stack)
-
7: Find system call handler
-
8: Run handler (index via table of pointers of syscall handles)
-
9: Return to user mode
-
10: Return to user program (via trap/interrupt)
-
11: Clean up
-
Address space
-
Parameter (in reverse order)
-
System call # in CPU register
-
Switch from user mode to kernel mode and back
-
Trap (a interrupt) interrupt ⇒ interrupt vector ⇒ interrupt handler (ISR)
-
Use of stack (during system call) and clean up (before completion of system call)


System call :
- OS is trusted, user is not
- OS has super privileges, user does not
- Must take measures to prevent abuse
Function Call:
- Same User
- Same ‘domain of trust’
<aside>
💡 Cache is transparent
</aside>

Five Categories of System calls
-
Process Management
-
File management:
-
Device Management:
- mkdir():
- rmdir():
- link()
- unlink()
- mount()
- unmount()
-
Information management
- stat()
- times(): Process running time
- getrusage(): Resource usage
- clock_gettime(): Get system time
-
Communication
- pipe()
- shmger(): share memory b/t processes
- mmap(): maps virtual memory
- socket(): network socket
- connect(): connect to a remote server
- accept(): accept remote connection
- send(): send network messages
System Call Parameter Passing: Memory, Address, stack
Passing parameters to the OS when making a system call depends on the type of call. For example, opening a file requires the file name, access mode and type. Getting system time requires the format and zone. These parameters must be passed in a data structure such as an array, list or structure.

Operating System Structures
⇒ There are six types of OS structures

<aside>
💡 C library is portable. because this ensures that code written using the library can be easily ported to different systems with a C compiler, regardless of operating system and hardware.
</aside>
graph TD
GCc --> O/S1
O/S1 --> P1
GCC --> O/S2
O/S2 --> P2
GcC --> O/S3
O/S3 --> P3
- Monolithic Structure/Simple Structure:
- A single large executable containing all the functions of the operating system, including process management, memory management, and file system management. (Main will contain minimum code)
- DOS has no modern software engineering techniques
- Allow all program direct access to hardware
- Does not break the system into sub-systems
- Debugging is very tedious.

- Layered Structure:
- A hierarchical approach in which the operating system is divided into a number of layers, each layer building on the functionality of the lower layer.
- This allows for modular design and easier maintenance of the operating system.
- Break the OS into smaller layers