CSOPESY_introduction_OS_up_to_computing_environments
This note has not been edited yet. Content may be subject to change.
original file
Introduction
What Operating Systems Do
- OS is a software, manages computer hardware and provides a basis for application programs
- user view: varies by device (PC, mobile, embed)
- goal: ease of use, performance
- embedded systems: computers working to control something, the goal is to run without user intervention
- system view
- OS acts as a resource allocator (managing CPU, mem, storage)
- acts as control program (prevents errors, improper use)
- kernel: core of the OS, program running at all times
- system programs - associated with the OS, not necessarily part of the kernel
- middleware - framework that provides additional services for application devs
- it's the basic code that can run everything
- sockets are like middleware so you can send/receive something over the network
buffer overflow - enroach onto another program and reach havoc of it → the OS handles that problem
user ↔ app programs ↔ operating system → computer hardware
Windows Operating System Components
(see picture in slides)
- user mode and kernel mode
- dll are the libraries you use (dynamic link libraries) so that you can use the hardware
Linux Operating System Structure
(see picture in slides)
- also has libraries to connect to the kernel
Android Operating System Structure
(see picture in slides)
-
uses linux kernel
-
included a hardware abstraction layer
-
java/python was implemented because applications are machine-specific (? didn't hear this properly)
-
java and python are slow against c because c/c++ are native
Computer System Organization
- Hardware: a system has one or more CPUs and device controllers (like USB) connected via a common bus
- each device controller → has device driver software
- device driver: understands controller, provides rest of the OS with a uniform interface to the device (ex. keyboards are HID-compliant)
- Interrupts: primary mechanism for hardware to signal the CPU
- a signal from the hardware to the CPU
- when it occurs, the CPU saves its state, abandons whatever its doing, and transfers execution to a dedicated interrupt handler - interrupt service routine; when finished, it "exits" from that code and goes back to what it was doing (similar to a function)
- Storage Structure: hierarchy of storage based on speed, size, and cost
- Volatile: main memory (DRAM)
- Nonvolatile: HDDs and nonvolatile memory (NVM) devices
- Direct Memory Access (DMA): a controller that transfers data directly between a device and memory, freeing the CPU from this task
what does SASM do?
- when you compile something, it turns into assembly code. c also tells it to convert the assembly code to machine code
- when you use the print or get macro in SASM, we are using an interrupt
Interrupt
(see diagram in slides)
the interrupt handler is just a set of software within the same CPU, think of function usage
- Interrupt Mechanism: hardware signals the CPU to request service
- CPU saves state and transfers execution to an interrupt handler routine
- this routine services the interrupt and then the CPU resumes the original task
- Interrupt-Driver I/O: ...
- Interrupt Vector: you have a lot of devices that have its own interrupt handler/service routine. a table of pointers to interrupt service routines stored in low memory ...
- an interrupt/vector number is used as an index into this table to quickly find the correct handler
- Types
- Non-maskable Interrupts: there are some interrupts that cannot be turned off. reserved for critical, unrecoverable events (memory errors)
- Maskable Interrupts: can be turned off by the CPU for critical instruction sequences, used by device controllers
- Interrupt Priority: a system of priority levels allow the CPU to handle high priority interrupts before low priority ones …
Storage
(see diagram of hierarchy on slides)
- Storage Hierarchy: organized based on speed, cost, and volatility. the closer to the CPU, the faster and more expensive the memory
- main memory (RAM):
- volatile: loses contents when power is turned off
- directly accessible by the CPU
- secondary storage:
- non volatile: stores data permanently
- HDDs and NVM devices
- Direct Memory Access (DMA): a controller that transfers data directly between a device and memory, freeing the CPU from this task (because it's usually a 2-step task of I/O → CPU → memory)
Computer System Architecture
- Single-Processor Systems: a single CPU with one core, plus special-purpose processors for devices
- Multiprocessor Systems: systems with multiple CPUs or cores that can run tasks in parallel
- Symmetric Multiprocessing (SMP): each processor is a peer and can perform all tasks
- this one is older
- there are processor0 (with CPU0) and processor1 (with CPU1) and each are directly connected to the main memory
- Multicore Systems: multiple cores on a single chip, which is more efficient
- both CPU core0 and core1 have their own L1 caches and connect to a common L2 cache
- Symmetric Multiprocessing (SMP): each processor is a peer and can perform all tasks
- Clustered Systems: multiple individual systems (nodes) linked together for high availability and high-performance computing ([multiple computers](Distributed System vs. Clustered System - GeeksforGeeks) interconnected and working together)
Operating System Operations
- Bootstrap Program: firmware (piece of software) code that loads the kernel when the computer starts, loads the operating system
- OS is in the secondary memory
- when you dual-boot you can choose what OS to start up
- multiprogramming & multitasking: techniques to keep the CPU busy by running multiple processes concurrently
- dual-mode operation: provides user mode and kernel mode to protect the OS from malicious user programs (with the mode bit indicating the current mode)
- timer: hardware timer interrupts the CPU after a specified periodm ensuring the OS maintains contro and prevents a single process from running indefinitely
round-robin technique to make it look like all the programs are running together
Multi-tasking Systems
- the OS must ensure reasonable response time
- common method for doing so is virtual memory, a technique that allows the execution of a process that is not completely in memory
- enables users to run programs that are larger than actual physical memory (because it uses the storage alongside physical memory and just keeps swapping)
- abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory
- frees programmers from concern over memory-storage limitations (like in python, java, unless you're using malloc in C)
Kernel and User Mode
(see diagram on slides)
- OS and the users share the hardware and software resources of the computer system
- must ensure that an incorrect or malicious program cannot cause other programs to execute incorrectly
- operating system must be able to distinguish between execution of OS code and user-defined code
- most computer systems provide hardware support that allows differentiation among various modes of execution thru the mode bit
Resource Management
- Process Management: OS creates, deletes, schedules, and synchronizes processes
- Memory Management: the OS tracks and allocates memory to processes, deciding what pages to move in and out of physical memory
- File-System Management: the OS provides a logical view of storage and manages file and directory structures
- Mass-Storage Management: the OS manages disk scheduling, free-space allocation, and partitioning for secondary storage
- Caching: data copied to a faster storage system (cache) to improve performance
- OS manages movement of data in storage hierarchy
- so that file access is faster
when you delete a file - means it went to a different directory, it's just marked "deleted" in the file header
Process Management
- Process Definition: program in execution
- a process needs resources like CPU time, memory, and I/O devices to accomplish its tasks
- process lifecycle
- a process is a passive entity like a file that becomes active when loaded into memory
- multiple processes …
Memory Management
…
Security and Protection
- Protection: a mechanism for controlling access of programs, processes, or users to system resources
- mechanism must provide means to specify the controls to be imposed and to enforce the controls
- reliability can be improved by detecting latent errors at the interfaces between component systems
- security: defends the ...
- user IDs and group IDs: used to distinguish users and groups
sudo → u want to do something on the system itself → escalating privileges
….
Kernel Data Structures
CS 1332 Data Structures and Algorithms Visualizations
-
Lists: used to represent collections of data values as a sequence, can be singly linked, doubly linked, or circularly linked. (uses pointers)
-
Stacks: LIFO
- heap and stack can collide because stack is going up, heap is going down
-
Queues: FIFO
-
Trees: used to represent data hierarchically
- Hash Maps: used to associate keys with values for fast data retrieval
- Bitmaps: string of binary digits used to represent the status of items, such as free disk blocks
Virtualization
- abstract the hardwrae of a single computer into multiple execution environments
- allows multiple OS to run concurrently, provides isolation between environments, facilitates system development
- Emulation is different, you're simulating computer hardware in software which is typically used when the source CPU type is different from the target CPU type
- Cloud Computing: major form of virtualization where resources are delivered as a service over a netwrok
Distributed Systems
- collection of separate, networked computers that provide a unified environment
- advantages: resource sharing, computational speedup, improved reliability
- …
Computing Environments
- Traditional Computing
- Mobile Computing
- Client-Server Computing
- Peer-to-Peer Computing (kind of a hybrid server, the trackers are like servers)
- Cloud Computing
- Real-Time Embedded Systems