[OS] Introduction 2
Updated:
Introduction Part 2
Computer-System Architecture
- Single-processor
- Multi-processor (parallel systems)
- Increased throughput
- Economy of scale : shared common resources
- Increased reliability : if one CPU have problem, then other CPU can do the task
- Assymmetric Multiprocessing : each processor is assigned a task
- Symmetric Multiprocessing : each processor performs all tasks
- Multi-core : communicate within one chip, so faster than Multi-processor
Operating System Structure
- Multiprogramming (Batch System) : needed for efficiency
- Single user cannot keep CPU and I/O devices busy at all times
- Multiprogramming organizes jobs so CPU always has one to execute
- A subset of total jobs in system is kept in memory
- One job selected and run via job scheduling
- When it has to wati(ex.I/O interrupt), OS switches to another job.
- Timesharing(multitasking) : CPU switches jobs so frequently that users can interact with each job while it is running
- Several users use 1 CPU
- Response time should be < 1 second
- Each user has at least one program executing in memory (process)
- If several jobs are ready to run at the same time, Os schedules CPU (CPU scheduling)
Operating System Operations
- Interrupt driven
- Hardware interrupt (by one of the devices) : occurs asynchronously (at any time)
- Software interrupt (exception or trap)
- Software error (ex. division by zero)
- Request for operating system device
- Other process problems include infinite loop, processes modifying each other in the OS
- Exception : synchronous interrupts, generated by CPU at the end of the instruction
- Trap : kind of exception typically with the purpose of debugging
- Dual mode
- Dual-mode operation allows OS to protect itsef and other system components
- User mode (mode bit : 1)
- Kernel mode (mode bit : 0)
- Mode bit is provided by hardware
- provides ability to distinguish when system is running user code or kernel code
- some instructions designated as privileged, only executable in kernel mode
- system call changes mode to kernel, return from call resets it to user
Transition from User to Kernel Mode
- Initial phase is controlled by operating system, and instructions are executed on kernel mode
- If user process get the control, then mode change to user mode (mode bit : 1)
- Operating system regain the control by interrupt, trap and system call
-
The application runing on user mode use system call to get authorized service by kernel mode
- Timer
- It is important to guarantee that operating system can continue the control of CPU
- Timer used to prevent the case if user program is in infinite loop or failure of system call eg.
- In the kernel mode, OS set a timer to generate an interrupt after some time period (privileged instruction)
- In the user mode, an application process keeps using the CPU
- The timer generates a timer interrupt when the timer expires (switched to the kernel mode)
- The OS can make a decision on the process
Process Management
- Program
- A collection of instructions that can be executed by a computer to perform a specific task
- passive entity (static : “saved” state)
- Process
- A program in execution, a unit of work within the system
- active entity (dynamic : working in main memory)
- Process needs resources (CPU, memory, I/O, files, etc…) to accomplish its task
- Process termination requires reclaim of any reusuable resources (OS takes all back)
- Single-threaded process has one program counter specifying location of enxt instruction to execute
- Process executes instructions sequentially, one at a time, until completion
- Multi-threaded process has one program counter per thread
Process Management Activities
The operating system is responsible or the following activities in connection with process management
- Creating and deleting both user and system processe
- Suspending and resuming processes
- Providing mechanisms for process synchronization
- Providing mechanisms for process communication
- Providing mechanisms for deadlock handling
Memory Management
- To execute a program, all of the instructions must be in memory
- All of the data that is needed by the program must be in memory
- Memory management determines what is in memory and when optimizing CPU utilization and computer resources to users
Memory Management Activities
- Keeping track of which parts of memory are currently being used and by whom
- Deciding which processes and data to move into and out of the memory
- Allocating and deallocating memory space as needed
Storage Management
- OS provides uniform, logical view of information storage
- File : abstracts physical properties to logical storage unit
- Each medium is controlled by device (ex. disk drive, tape drive)
File-System Management
- Files usually organized into directories
- Access control on most systems to determine who can access what
- OS activities include
- Creating and deleting files and directories
- Primitives to manipulate files and directories
- Mapping files onto secondary storage
- Backup files onto stable(non-volatile) storage media
Mass-Storage Managment
- Usually disks used to store data that does not fit in main memory or data that must be kept for a long period of time
- OS activities include
- Free-space managemnet
- Storage allocation
- Disk scheduling
Performance of various levels of storage
Migration of data “A” from disk to register
- Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy
- Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache
- Assume client A (process A) and client B (process B) share the variable “X”, and the value is 0
- After Client A write 1 to variable X, Client B read the variable X
- Variable X that client B read have the value “0”, but Client A have the variable X = 1
- This is data dismatch problem, so it is important to control cache coherency
I/O subsystem
I/O subsystem responsible for memory managemnt of I/P
- Buffering : storing data temporarily while it is being transferred
- Caching : storing parts of data in faster storage for performance
- Spooling : copying data between different devices, usually fast -> slow device
Protection and Security
- Protection : any mechanism for controlling access of processes or users to resources
- Security : defense of the system against internal and external attacks
Computing Environments - Virtualization
- Allows operating system to run applications within other OS
- VMM (Virtual machine manager) provides virtualization services
- VMM control the access for resource
Leave a comment