Mechanism: Address Translation
Mechanism: Address Translation
CPU: limited direct execution (LDE)
In virtualizing memory, we will pursue efficiency and control.
CRUX: How to efficiently and flexibly virtualize memory?
Technique: hardware-based address translation / address translation, changing the virtual address provided by the instruction to a physical address.
Interposition is powerful: On of the usual benefits of such an approach is transparency.
Dynamic (Hardware-based) Relocation
base and bounds / dynamic relocation:
...
Interlude: Memory API
Interlude: Memory API
CRUX: How to allocate and manage memory in UNIX/C programs?
Types of Memory
stack memory: allocations and deallocations are managed implicitly by the compiler. For this reason it is sometimes called automatic memory.
Declaring memory on the stack in C is easy. For example, let’s say you need some space in function func() for an integer, called x. To declare such a piece of memory, you just do something like this:
123void func() { int x;}
The compiler does the res ...
The Abstraction: Address Spaces
The Abstraction: Address Spaces
Early Systems
From the perspective of memory, early machine didn’t provide much of an abstraction to users. The OS was a set of routines (a library, really) that sat in memory (starting at physical address 0, for example), and there would be one running program (a process) that currently sat in physical memory and used the rest of memory.
Multiprogramming and Time Sharing
multiprogramming: multiple processes were ready to run at a given time, and the OS would swit ...
Scheduling: Proportional Share
Operating Systems: Three Easy Pieces
We will examine a different type of scheduler known as a proportional-share scheduler, also sometimes referred to as a fair-share scheduler.
An early example of proportional-share scheduling is known as lottery scheduling. The crux is how can we design a scheduler to share the CPU in a proportional manner?
Basic Concept: Tickets Represent Your Share
tickets: used to represent the share of a resource that a process (or user) should receive.
Lottery allocate ...
Scheduling: The Multi-Level Feedback Queue
Scheduling: Introduction
Workload Assumptions
A number of simplifying simplifying assumptions about the process running in the system, sometimes collectively called the workload. We will make the following assumptions about the processes, sometimes called jobs, that are running in the system:
Each job runs for the same amount of time.
All jobs arrive at the same time.
Once started, each job runs to completion.
All jobs only use the CPU.
The run-time of each job is known.
Scheduling Metrics
Tur ...
Mechanism: Limited Direct Execution
Mechanism: Limited Direct Execution
A few challenges:
Performance
Control
Basic Technique: Limited Direct Execution
OS:
Create entry for process list.
Allocate memory for program.
Load program into memory.
Set up stack with argc/argv.
Clear registers. Execute call main().
Program:
Run main().
Execute return from main.
OS:
Free memory of process.
Remove from process list.
Problem #1: Restricted Operations
What if the process wishes to perform some kind of restricted operation, such a ...
Operating Systems: Process API
Interlude: Process API
The fork System Call
123456789101112131415161718192021#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(int argc, char *argvp[]) { printf("hello world (pid:%d)\n", (int) getpid()); int rc = fork(); if (rc < 0) { // fork failed fprintf(stderr, "fork failed\n"); exit(1); } else if (rc == 0) { // child (new process) printf("hello, I am child (pid:%d)", (int) getpid()); ...
Operating Systems: The Process
Operating Systems: Three Easy Pieces
The Abstraction: The Process
One of the most fundamental abstractions that the OS provides to users: the process (a running program).
The OS creates the illusion of nearly-endless supply of CPUs by virtualizing the CPU.
The basic technique, known as time sharing (分时) of the CPU, allows users to run many concurrent processes.
To implement virtualization of the CPU, and to implement it well, the OS will need both some low-level machinery and some high-level i ...
Operating Systems: Introduction
Introduction
Computer Systems: Three Easy Pieces
Virtualization: the OS takes a physical resource and transforms it into a more general, powerful, and easy-to-use virtual form of itself. Thus, the OS is sometimes referred to as a virtual machine.
A typical OS exports a few hundred system calls that are available to applications. The OS provides a standard library to applications.
The OS is sometimes known as a resource manager for CPU, memory, and disk.
Virtualizing
123456789101112131415161718 ...
Seeing Is Believing?
Seeing is believing. It used to be such a universally acknowledged viewpoint that almost all languages, eastern or western, possess similar expressions. Throughout history, this common idea has guided us and encouraged our ancestors to seek the truth, and, to some extent, it also leads to the advent of experimental science and other branches of scientific knowledge. With a deeper understanding of the world we live, people begin to doubt and challenge this proverb. Given the interest in, debate o ...