- When the shell loaded and ran the HelloWorld program, and when the HelloWorld program prints its message, neither program accessed the keyboard, display, disk, or main memory directly.
- Rather, they relied on the services provided by the operating system.
-
We can think of the operating system as a layer of software interposed between the application program and the hardware.
- An operating system is software that manages all the hardware resources associated with your electronic devices.
- It manages the communication between your software and hardware.
- Without the operating system (OS), the software wouldn’t function.
- Examples: Windows 8 and Mac OS X, Linux
- Daemons: These are background services (printing, sound, scheduling, etc) that either start up during boot, or after you log into the desktop.
- The Shell: is a user interface that allows you to control the computer. OS shells use either command-line interface (CLI) or graphical user interface (GUI). It is named a shell because it is a layer around the OS kernel.
- Graphical Server: This is the sub-system that displays the graphics on your monitor.
-
Desktop Environment: This is the piece of the puzzle that the users actually interact with. Each desktop environment includes built-in applications (such as file managers, configuration tools, web browsers, games, etc)
- The operating system has two primary purposes:
- To protect the hardware from misuse by runaway applications and
- To provide applications with simple and uniform mechanisms for manipulating complicated and often widely different low-level hardware devices.
- The operating system achieves both goals via the fundamental abstractions
- Processes
- Virtual memory
- Files
- A process is the operating system’s abstraction for a running program.
- Multiple processes can run concurrently on the same system, and each process appears to have exclusive use of the hardware.
- Many running program share the physical memory space.
- Each runnning program is presented with the illusion that they have access to their own private memory. This is called virtual address space, which is mapped to physical memory space by the OS.
- Making memory references within one running program (within one’s own virtual address space) does not affect the private virtual address space of others.
-
By concurrently, we mean that the instructions of one process are interleaved with the instructions of another process.
- The transition from one process to another is managed by the operating system Kernel.
- The kernel is the portion of the operating system code that is always resident in memory.
- When an application program requires some action by the operating system, such as to read or write a file, it requires some action by the operating system, such as to read or write a file, it executes a special system call instruction, transferring control to the kernel.
- The kernel then performs the requested operation and returns back to the application program.
-
Note that the kernel is not a separate process. Instead, it is a collection of code and data structures that the system uses to manage all the processes.
- CPU receives interrupt
- Interrupt stores in program counter
- Interrupt invokes handler
- Handler saves rest of process state
- Handler does its business
- Handler invokes the scheduler
- Scheduler selects a process to run
- Scheduler restores state for that process
-
Scheduler jumps execution to that process
- Rule 1: If Priority(A) > Priority(B), A runs (B doesn’t)
- Rule 2: If Priority(A) = Priority(B), RR(A, B)
- Rule 3: When a job enter the system, it is placed at the highest priority (the top most queue).
- Rule 4: Once a job uses up its time allotment at a given level (regardless of how many time it has given up the CPU), its priority is reduced.
- Rule 5: After some time period S, move all the jobs in the system to the topmost queue.
- MLFQ observes the execution of a job and gradually learns what type of job it is, and prioritize it accordingly.
- Excellent performance for interactive I/O bound jobs: good response time.
- Fair for long-running CPU-bound jobs: good turnaround time without starvation.
- Used by many systems, including FreeBSD, MacOS X, Solaris, Linux 2.6, and Windows NT
- Invented by Fernando Jose Corbato (1926 - )
- Ph.D. in Physics (CalTech)
- MIT Professor
- One of the original developers of Multics (Predecessor of UNIX)
- First use of password to secure file access on computers.
- Recipient of the 1990 Turing Award (The Nobel prize in computing)
- A process can be in one of the three states.
- Running: the CPU is executing a process’ instructions.
- Ready: the process is ready to run, but the OS is not running the process at the moment.
- Blocked: the process has to perform some operation (e.g., I/O request to disk) that makes it not ready to run.