Notes/UNB/Year 4/Semester 1/CS3418/9-18-2023.md
2024-01-22 10:12:48 -04:00

3.0 KiB

Lecture Topic: Operating System Services

Operating systems provide an environment for execution of programs and services to programs and users

Some of these services are:

  • User Interface (CLI, GUI, Touch Screen)
  • Program Execution: Load the program into memory, run, and end execution either normally or abnormally (errors)
  • I/O operations: Files, I/O device
  • File system manipulation: Supports the reading, writing of files and directories, create and delete, search, list file metadata and permission management of files and directories

There are 2 ways to design CLI:

  • Executing the program by jumping directly into the program code
  • Creating a new process and then invoking the program in that new process

A few sets of services that are helpful are:

  • Communication between different processes on the same PC, and computers on the network, either by shared memory or message passing (packets)
  • Error handling/detection
  • Resource allocation: multiple users or jobs are running concurrently and resources need to be shared, like CPU cycles, memory, storage, IO devices
  • Logging
  • Protection and Security, protection being that all access to system resources are controlled and security is protecting the OS from outsiders, by using authentication

System Calls: Programming interface provided by OS, typically written in C or C++, usually accessed with a high level API, not using direct system calls. Common examples would be the Win32 API, the POSIX API for Linux, Unix, BSD, macOS, or the Java API for the JVM

Typically a number is associated with each system call, the System-call interface maintains a tabled indexed according to these numbers. The system call interface invokes the intended system call and the OS returns the status and any other return values. The caller need to know nothing about how the system call is implemented. They just need to obey the API and understand what the OS will return

Often more information is required than simply the identity of the system call. Three methods are generally used to pass information to the OS

  • Simplest: Pass the parameters in registers. In some cases there are more parameters than registers
  • Parameters are stored in a block/table in memory and then pass the address of the block and pass it in as a parameter
  • Parameters and placed on the stack and then popped of the stack as used

Linkers and Loaders: When source code is compiled it is loaded into a physical memory location - relocatable object file. A linker combines these into a single binary executable file (also brings in libraries).

  • Program resides on secondary storage as binary executable.
  • Must be brought into memory by loader to be executed
  • Relocation assigns final addressed to program parts and adjusts code and data in program to match those address
  • Modern general purpose systems don't link libraries into executables, rather using dynamically linked libraries that are loaded as needed, shared by all that use the same version of the same library
  • Object and executable files have standard formats so operating system knows how to load and start them