We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
What is an OS?
and why should I care?
Who am I?
- Software Engineer
- Red Hat for 3 years
- BHS for 3 years
- Bachelor’s from USC
- OMSCS @ GT
- GIOS
- AOS
- Red Hat for 3 years
- BHS for 3 years
- GIOS
- AOS
What is an OS?
An operating system (OS) is system software that manages computer hardware and software resources, and provides common services for computer programs.
The Almighty Wikipedia
The Almighty Wikipedia
Diagram
Goals
- Abstraction
Goals
- Abstraction
- Flexibility
- Extensibility
- Extensibility
Goals
- Abstraction
- Flexibility
- Extensibility
- Performance
- Extensibility
Goals
- Abstraction
- Flexibility
- Extensibility
- Performance
- Protection
- Within and across app/os boundaries
- Extensibility
- Within and across app/os boundaries
Goals
- Abstraction
- Flexibility
- Extensibility
- Performance
- Protection
- Within and across app/os boundaries
- Scalability
- Extensibility
- Within and across app/os boundaries
Goals
- Abstraction
- Flexibility
- Extensibility
- Performance
- Protection
- Within and across app/os boundaries
- Scalability
- Responsiveness
- Extensibility
- Within and across app/os boundaries
The Big 3
- Linux
- MacOS
- Windows
Components
- VMM
- Scheduler
- Drivers
Components
Components
Components
Component Overview
What are the responsibilities of the components?
Drivers
> ls /usr/src/linux/drivers/ | wc -l
145
> ls /usr/src/linux/drivers/ | wc -l
145
Drivers
/usr/src/linux/drivers/scsi/wd719x.h
/* timeout delays in microsecs */
#define WD719X_WAIT_FOR_CMD_READY 500
#define WD719X_WAIT_FOR_RISC 2000
#define WD719X_WAIT_FOR_SCSI_RESET 3000000
/* All commands except 0x00 generate an interrupt */
#define WD719X_CMD_READY 0x00 /* Command register ready (or noop) */
#define WD719X_CMD_INIT_RISC 0x01 /* Initialize RISC */
/* 0x02 is reserved */
#define WD719X_CMD_BUSRESET 0x03 /* Assert SCSI bus reset */
#define WD719X_CMD_READ_FIRMVER 0x04 /* Read the Firmware Revision */
#define WD719X_CMD_ECHO_BYTES 0x05 /* Echo command bytes (DW) */
/* 0x06 is reserved */
/* 0x07 is reserved */
#define WD719X_CMD_GET_PARAM 0x08 /* Get programmable parameters */
#define WD719X_CMD_SET_PARAM 0x09 /* Set programmable parameters */
#define WD719X_CMD_SLEEP 0x0a /* Put SPIDER to sleep */
#define WD719X_CMD_READ_INIT 0x0b /* Read initialization parameters */
#define WD719X_CMD_RESTORE_INIT 0x0c /* Restore initialization parameters */
/* 0x0d is reserved */
/* 0x0e is reserved */
/* 0x0f is reserved */
#define WD719X_CMD_ABORT_TAG 0x10 /* Send Abort tag message to target */
#define WD719X_CMD_ABORT 0x11 /* Send Abort message to target */
#define WD719X_CMD_RESET 0x12 /* Send Reset message to target */
#define WD719X_CMD_INIT_SCAM 0x13 /* Initiate SCAM */
#define WD719X_CMD_GET_SYNC 0x14 /* Get synchronous rates */
#define WD719X_CMD_SET_SYNC 0x15 /* Set synchronous rates */
#define WD719X_CMD_GET_WIDTH 0x16 /* Get SCSI bus width */
#define WD719X_CMD_SET_WIDTH 0x17 /* Set SCSI bus width */
#define WD719X_CMD_GET_TAGS 0x18 /* Get tag flags */
#define WD719X_CMD_SET_TAGS 0x19 /* Set tag flags */
#define WD719X_CMD_GET_PARAM2 0x1a /* Get programmable params (format 2) */
#define WD719X_CMD_SET_PARAM2 0x1b /* Set programmable params (format 2) */
Drivers
Provide hardware-level abstraction
ret = fread(buffer, sizeof(*buffer), ARRAY_SIZE(buffer), fp);
if (ret != ARRAY_SIZE(buffer)) {
fprintf(stderr, "fread() failed: %zu\n", ret);
exit(EXIT_FAILURE);
}
corresponds to rotating the platter and moving the needle
Kernel
The kernel is responsible for scheduling processes, managing memory, and orchestrating drivers
It is also typically loaded entirely into memory
Kernel
Kernel
Scheduler
Run a thread for a while, block for IO, run a different thread in the meantime
Scheduler
Run a thread for a while, block for IO, run a different thread in the meantime
ret = fread(buffer, sizeof(*buffer), ARRAY_SIZE(buffer), fp);
if (ret != ARRAY_SIZE(buffer)) {
fprintf(stderr, "fread() failed: %zu\n", ret);
exit(EXIT_FAILURE);
}
Scheduling Policies
- First Come First Serve (FCFS)
- Ignores affinity for fairness
- Fixed processor
- Predetermined processor
- Last processor
- Prefer last processor that thread ran on
- Minimum Intervening
- Similar to Last Processor, but lower affinity the more threads that ran on processor since last time this thread ran
- Ignores affinity for fairness
- Predetermined processor
- Prefer last processor that thread ran on
- Similar to Last Processor, but lower affinity the more threads that ran on processor since last time this thread ran
Virtual Memory Manager
Key benefit is to trick process into thinking it has a memory space all to itself
Virtual Memory Manager
Key benefit is to trick process into thinking it has a memory space all to itself
Also allow for more “memory” than hardware allows
Virtual Memory Manager
Virtual Memory Manager
Contiguous Memory Allocation
std::vector<int> arr = {0, 1, 2, 4, 5};
int sum = 0;
for (int i = 0; i < arr.size(); i++) {
sum += arr[i];
}
Virtual Memory Manager
Virtual Memory Manager
Virtual Memory Manager
Virtual Memory Manager
Virtual Memory Manager
Virtual Memory Manager
Structures
- Monolithic
- DOS-like
- Microkernel
Monolithic
Each app has its own hardware address/memory space
OS in its own hardware address space
Malfuntioning of an app shouldn’t affect integrity of OS nor other apps
Monolithic
DOS-like
Monolithic structure where there is no protection between the apps and the OS
- Application code can make syscalls directly, like they would any other library
This was in a time where multitasking didn’t really exists and PCs were meant for single users
Microkernel
Microkernels were designed to focus around customization for a specific application
The microkernel itself handles simple abstractions like address space, IPC, etc.