CS330 - Operating Systems
Understanding OS Services, Interfaces, and Architecture
Operating systems provide an environment for execution of programs and services to programs and users. Services are divided into those that are helpful to the user and those that ensure efficient operation of the system.
Almost all operating systems have a user interface. Varies between Command-Line Interface (CLI), Graphical User Interface (GUI), or both.
System capability to load a program into memory and run it. OS able to end execution either normally or abnormally.
Since user programs cannot execute I/O operations directly, the OS must provide means to perform I/O.
Ability to read, write, create, open, close and delete files/directories.
Exchange of information between processes on the same computer or different systems via shared memory or message passing.
Ensure correct computing by detecting errors in CPU, memory hardware, I/O devices, or user programs.
Shows the relationship between User, OS Services, and System
| Aspect | CLI | GUI |
|---|---|---|
| Speed | Faster for experienced users | Slower but more intuitive |
| Resource Usage | Low memory/CPU usage | Higher resource requirements |
| Learning Curve | Steep - must memorize commands | Gentle - visual and intuitive |
| Automation | Easy to script and automate | Harder to automate tasks |
| Precision | Very precise control | Less precise, more general |
System calls provide an interface between a running program and the operating system. They are generally available as assembly language instructions and accessed through high-level language API.
Shows transition from user mode to kernel mode
| Category | Functions | Examples |
|---|---|---|
| Process Control | end, abort, load, execute, create/terminate process, get/set attributes, wait | fork(), exit(), wait(), exec() |
| File Management | create, delete, open, close, read, write, reposition, get/set attributes | open(), close(), read(), write(), lseek() |
| Device Management | request/release device, read, write, reposition, get/set attributes | ioctl(), read(), write() |
| Information Maintenance | get/set time or date, get/set system data, get/set process attributes | getpid(), alarm(), sleep() |
| Communications | create/delete connection, send/receive messages, transfer status | pipe(), shmget(), socket() |
| Protection | get/set permissions, allow/deny access | chmod(), umask(), chown() |
Dual-mode operation allows OS to protect itself and other system components. The hardware provides a mode bit to distinguish between user code and kernel code execution.
Q: What happens when a user program tries to execute a privileged instruction in user mode?
General-purpose OS is a very large program. Various ways exist to structure operating systems, each with advantages and disadvantages.
Example: MS-DOS, Original UNIX
Modular OS structure with loadable kernel modules
Most modern operating systems are not one pure model but combine multiple approaches:
| Structure | Advantages | Disadvantages | Examples |
|---|---|---|---|
| Simple/Monolithic | Fast, efficient | Hard to maintain, not secure | MS-DOS, early UNIX |
| Layered | Modular, easy to debug | Performance overhead, hard to define layers | THE, OS/2 |
| Microkernel | Reliable, secure, portable | Performance overhead from messaging | Mach, QNX, Minix |
| Modular | Flexible, efficient, maintainable | Complexity in module interfaces | Linux, Solaris, Windows |
System programs provide a convenient environment for program development and execution. They can be divided into several categories.
Create, delete, copy, rename, print, dump, list files and directories
Date, time, memory usage, disk space, number of users, performance
Text editors to create and modify files, search contents
Compilers, assemblers, debuggers, interpreters
Loaders, linkers, and execution utilities
Email, web browsers, remote login, file transfer
The process of starting a computer by loading the kernel is known as booting the system.
Q1. Which of the following is NOT a benefit of a microkernel architecture?
Q2. In a layered operating system structure, each layer can only use services of:
Q3. Which system call category would chmod() belong to?
Q4. When a user program makes a system call, the mode bit changes from:
Q5. Which of the following was invented at Xerox PARC?
Q6. Explain the difference between user mode and kernel mode. Why is this distinction important? (5 marks)
Q7. Compare and contrast monolithic kernel and microkernel architectures. Give one advantage and disadvantage of each. (8 marks)
| Aspect | Monolithic Kernel | Microkernel |
|---|---|---|
| Structure | All OS services in kernel space | Minimal kernel, services in user space |
| Advantage | Fast performance (no message passing) | More reliable and secure |
| Disadvantage | Hard to maintain, less secure | Performance overhead from IPC |
| Example | Linux, Unix | Mach, QNX |
Q8. List and briefly describe five types of system calls with one example each. (10 marks)
| Term | Definition |
|---|---|
| System Call | Interface between running program and OS kernel |
| API | Application Programming Interface - set of functions available to programmers |
| Shell | Command interpreter that provides user interface to OS |
| Kernel Module | Loadable kernel component that extends OS functionality |
| Mode Bit | Hardware bit distinguishing user mode (1) from kernel mode (0) |
| Privileged Instruction | CPU instruction only executable in kernel mode |
| Bootstrap Loader | Program that loads OS kernel during system boot |
| IPC | Inter-Process Communication - message passing between processes |
| System Program | Program that provides environment for program development/execution |