Operating Systems 2018F Lecture 1: Difference between revisions
R.samanfar (talk | contribs) |
R.samanfar (talk | contribs) |
||
Line 122: | Line 122: | ||
**journaling or copy-on-write | **journaling or copy-on-write | ||
<center>'''END OF LECTURE 1'''</center> | <center>'''END OF LECTURE 1'''</center> | ||
Revision as of 17:59, 12 September 2018
Video
Video from the lecture given on September 5, 2018 is now available.
Code
Code and files from the lecture (captured as they were at the end) are available here.
Notes
Introduction
why is an operating system important?
- Only certain programs run on certain operating systems
- Customization
- Interface
We program at different levels of abstraction
- Abstraction - make system easy to use, divide program into smaller understandable
pieces
- most portable - the web
- works on almost all operating systems
- the web browser is an operating system (eg: chromebook)
How do programs run at the same time?
- Originally, one program used to control the whole system, now for example there are
around 270 threads running at once on a laptop
- A program executes instructions → the processor fetches an instruction from
memory, decodes it and executes it
- Similar to a political system: Authoritarian dictatorship
- Virtualizing the CPU: illusion that a single CPU has a large number of smaller virtual
CPUs.
- Policy: to determine which program runs first
Operating systems
- body of software to determine which programs to run, allow programs to share memory,
enabling programs to interact with devices
- the OS takes a physical resource (such as the processor, or memory, or a disk) and
transforms it into a more general, powerful, and easy-to-use virtual form of itself
- AKA virtual machine
- provides some interfaces (APIs) that you can call (system calls that are available to
applications to run programs, access memory and devices, and other related actions, aka standard library)
- Resource manager - give programs resources based on priorities
Goals:
- High performance
- Minimize overhead
- protection between applications
- Isolating processes
- Reliability(runs nonstop)
- Energy efficient
- Secure
- Mobility
Unix
- Has variants - linux, minux
- Programmed in C
Windows
- VMS
- Microsoft bought a team to build an operating system
Hello World - Sample Program
C programs start with main function
Compile and Run:
Two different ways to compile:
- One does more work and it is smaller
- One does less work and it is larger
How many lines of code are running in a system?
- 100 million lines of code!
Questions to ask:
- Who calls main?
- Where do the arguments come from?
- Who's taking the return value?
- Who defines headers? Where do they come from?
Mental Model
- Don’t need to know exactly what happens
- Know the strategy to figure it out
- Know when to ask the questions
- Know when it matters
- OS → the code that runs under the application
Who is in charge?
- the first program that runs on the system is in charge
- may delegate its powers to others
- make sure it only obeys your commands (self preservation)
- eg: if you get a command from someone else, ask me first
- add a level of abstraction: authorization
- downside: labour intensive (time consuming to approve every command)
- create rules to determine when authorization is needed
- when does the OS need to get involved
- this is costly, so leave instructions behind so that is can make decisions
- take charge of dangerous operations
Cpu modes:
- Supervisor mode: access to all hardware resources
- User mode: access to limited resources, as defined by code running in supervisor mode
Definitions:
- Kernel: code that runs in supervisor mode (If your code runs in supervisor mode, you are
in the kernel.)
- Process: “running program” (Processes run in user mode)
- System call: process making a request of the kernel (costly)
- portable: able to work on different operating systems, a program that can run in many
different environments. APIs
- an application programming interface (API) is a set of subroutine definitions,
communication protocols, and tools for building software
Memory
- read - address to access data stored there
- write - address and data to be stored there
- virtualizing memory - each process accesses its own private virtual address space
- The OS maps this memory to the physical memory on the machine
Concurrency
- working on many things at once in the same program
- multi-threaded programs
- thread: a function running within the same memory space as other functions
- race conditions
Presistence
- how do we not lose data
- volatile - when the system crashes, the data in this memory is lost (DRAM)
- hard drive - long term store
- solid state drive - alternative for hard drive
- file system - manages disk storage
- handling system crashes
- journaling or copy-on-write