0% found this document useful (0 votes)
22 views

01 Intro

This document provides an introduction and overview of the COL331/COL633 operating systems course. It discusses key topics that will be covered including computer organization, the purpose of an operating system for resource management, higher-level services, and protection/isolation. It also outlines the course structure where students will build an operating system from scratch to learn about booting, I/O, file systems, processes, concurrency, memory management and more. The document argues that operating systems remain an important area to study due to evolving computing trends like cloud, smartphones, and cyber-physical systems that require new OS techniques and designs.

Uploaded by

Manpreet Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

01 Intro

This document provides an introduction and overview of the COL331/COL633 operating systems course. It discusses key topics that will be covered including computer organization, the purpose of an operating system for resource management, higher-level services, and protection/isolation. It also outlines the course structure where students will build an operating system from scratch to learn about booting, I/O, file systems, processes, concurrency, memory management and more. The document argues that operating systems remain an important area to study due to evolving computing trends like cloud, smartphones, and cyber-physical systems that require new OS techniques and designs.

Uploaded by

Manpreet Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Introduction

COL331/COL633

Abhilash Jindal Reference. OSTEP book: Chapter 2


Administrivia

• http://abhilash-jindal.com/teaching/2023-2-col-331/
• Grading criteria, TAs, late policy, audit criteria, quizzes, labs, project, piazza
link

• Piazza access code: col331col633


Why does OS matter to a computer?
Computer organization

(Non-volatile)

CPU CPU Disk controller USB controller Graphics adapter

Memory (volatile)
Purpose of an OS

• Resource management
• Provide higher-level services
• Protection and isolation
Purpose of OS: Resource management

• Example: cpu.c
• Give the illusion of more CPUs than there are
• Multiplex the hardware
Operating system

Computer hardware
Calculator analogy: Computing long sum
• 2 0 = (move pointer to 10)
20
• + 1 0 = (move pointer to 30)
10
• + 3 0 = (move pointer to 50)
30

50
• + 5 0 = (move pointer to 30)
30 • + 3 0 = (move pointer to 10)
10 • + 1 0 = (move pointer to 20)
20
• + 2 0 = (move pointer to 10)
10
Sharing the calculator
• Steps to share the calculator:
20 10
• 20 + 10 = 30 + 30 = 60
10 70
• Write 60 in notebook, remember that we were done till
30 20 30, give calculator
50 40
• 10 + 70 = 80
30 20
• Write 80 in notebook, remember that we were done till
10 10 70, give the calculator back
20 50

10 10
Remember whatever is on the screen and give calculator?

• 2 0 = (move pointer to 10)


Can I give calculator
20 10
• + 1 0 = (move pointer to 30) here?
10 70
• + 3 0 = (move pointer to 50) “Save 1 and remember
30 20 pointer to be at 10”
50 40
• + 5 0 = (move pointer to 30)
No! Sum would be wrong!
30 20 • + 3 0 = (move pointer to 10)
“+ xx = (move pointer)” has
10 10 • + 1 0 = (move pointer to 20) to be atomic
20 50
• + 2 0 = (move pointer to 10)
10 10
Resource manager: multiplexing CPU
• CPU is also executing one instruction after another and incrementing “instruction
pointer”

• OS switches CPU between processes in the same manner as our calculator


example

• What should happen when multiple processes want to run simultaneously?


• Fairness: One banker got more calculator time than others
• Often need to break away from fairness. Game should get more CPU time than
Dropbox to provide good user experience

• Starvation freedom: When there are multiple bankers, one banker never got the
calculator
Purpose of OS: Resource manager
Di erent approaches to memory management:

• Segment di erent memory portions to di erent


processes

• Multiplex memory pages across processes

Operating system

.. .. ..
Computer hardware
Or
1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
ff
ff
ff
Memory management
• Segmentation is cheap to implement
• But not exible. What if a process needs more memory that what OS gave?
• Paging is complicated to implement
• Highly exible

.. .. ..

1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
fl
fl
Purpose of an OS

• Resource management
• Provide higher-level services
• Protection and isolation
Purpose of OS: Provide higher-level services

Example: io.c

Disk interface: List of blocks

File system OS interface: Folders and les

int fd = open("/tmp/file", O_WRONLY | O_CREAT);


Operating system int rc = write(fd, "hello world\n", 13);
close(fd);

Computer hardware 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
fi
Why file system?
Why not just multiplex disk blocks like memory?

• Disk blocks live after programs exits, computer restarts


• Di erent programs read / write same le
• vim writes io.c
• gcc reads io.c, write io
Operating system • We nally run io

Computer hardware 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
ff
fi
fi
Higher level services provide portability

• Abstract away hardware details


• Programs need not be rewritten when
moving from hard-disk drive to solid
state drive

int fd = open("/tmp/file", O_WRONLY | O_CREAT);


Operating system int rc = write(fd, "hello world\n", 13);
close(fd);

Computer hardware 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
Purpose of an OS

• Resource management
• Provide higher-level services
• Protection and isolation
Purpose of OS: Protection
• S_IRUSR | S_IWUSR: File can only be rw by user
• Disallow inappropriate accesses. Example: users
reading each other’s les

int fd = open(“/home/abhilash/exam.txt”, S_IRUSR | S_IWUSR);


Operating system int rc = write(fd, “Q1: \n”, 4);
close(fd);

Computer hardware 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
fi
Purpose of OS: Protection
• Disallow inappropriate accesses.
Example: processes reading each
other’s memory

Operating system

Computer hardware 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..
Purpose of OS: Isolation

• Example: mem.c
• Multiple processes access the same pointer
location but the OS isolated them with the
help of hardware

• Each process thinks they own the memory


Operating system

Computer hardware MMU 1 2 3 4 5 6 7 8 9 10 11 12 .. .. ..


Course structure: OS in action
• We will build an OS (xv6) from scratch
• Booting: Bootloader, ELF format
• Input-output: Programmable interrupt controllers, traps, interrupt descriptor table
• File system: FS layout, bu er cache layer, name layer, crash consistency, devices as les
• Processes: memory segmentation, rings, process table, context switching, scheduling,
system calls, exec system call

• Concurrency: data races, di erent types of locks


• Memory virtualization: memory hierarchy, address translation mechanism, demand paging,
thrashing, fork system call

• Shell: Pipes, IO redirection


• Parallelism: Enable more CPUs, revisit locks
ff
ff
fi
Data races due to concurrency
./threads 100000

Thread 1 Thread 2
Read counter = 0
Write counter = 1
Read counter = 1
Writer counter = 2
Read counter = 2
Read counter = 2
Writer counter = 3
Writer counter = 3
Why should I learn OS in 2024?
Isn’t it a solved problem?
We have indeed made good progress ..
Please run my job

Ok. I will. After


the 10 jobs in queue
are done!

Computer operators
1960s: Batch jobs
Personal
computers
1980s: Interactive jobs!
2000s: Cloud

VM1 VM2 VM3 • Cloud: I can rent virtual machines so I don’t have
to buy and manage servers.

• Hypervisor provides facilities to operating


OS OS OS systems that OS provides to processes

Hypervisor / • multiplexes hardware among OS


Virtual machine monitor
• protects and isolates OS from each other
Computer hardware
• Hypervisors fundamentally enabled cloud
computing
2000s: Smartphones
• New kinds of higher-level services: localisation,
cellular, accelerometer, touch interface, etc.

• Resource constraints: Power management, UI system,


etc.

• Even higher-level services: voice recognition,


augmented reality, etc.

• Increased security concerns because of increase in


sensitive data with rise of mobile banking, UPI etc.
and because of moving devices
2000s: Cyber-physical systems
OS must not crash! Formally veri ed OS. Example: seL4
fi
Typical progression of systems research
• Systems optimise for the “common case”
Users

• If common case changes, we need to rethink OS


design Applications

• Macro examples
Libraries
• Personal computers: batch jobs to interactive jobs
• Smartphones: resource constraints, new sensors Operating systems

• Cyber physical systems: risk of human life Hardware


More trends: persistent memory
• Memory: volatile but fast
• Disk: persistent but large
• PMEM: persistent and fast!
• PMEM aware le systems
fi
More trends: big memory
• OS were designed when memory was scarce: few KBs
• You can now buy a server with 12TB of DRAM!
• Transparent huge pages
More trends: fast networks
• OS typically assumed network is
much slower than DRAM

• Far memory 2020s Latency Bandwidth

DRAM 15ns 400 GBps

Ethernet 500ns 50 GBps


Rise of Unikernels

VM1 VM2 VM3 • OS optimises for common behaviours across


all applications

• Each OS is now running only single application


OS OS OS
• Unikernels optimise only for a single
application
Hypervisor /
Virtual machine monitor

Computer hardware
Why should I care about learning OS?
If I don’t want to do systems research

• OS is ultimately a study of abstraction. Absorb all the complexity away from


the developer / the user.

• Principles are useful when designing any large-scale system

You might also like