OS Exam 1 Study Guide

¡Supera tus tareas y exámenes ahora con Quizwiz!

cooperating process vs ind. process

ind process cannot affect or be affected by the execution of another process cooperating process can affect or be affected by the execution of another process reasons for cooperating processes information sharing computation speedup (parallelism) modularity convience

Light Weight Processes

intermediate data structure between user and kernel threads

Parallelism

multicore or multiprocessor systems putting pressure on programmers, challenges include dividing activities balance data splitting data dependency testing and debugging Parallelism implies a system can perform more than one task simultaneously Concurrency supports more than one task making progress single processor/core scheduler providing concurrency Data parallelism-distributes subsets of the same data across multiple cores, same operation on each Task parallelism-distributing threads across cores, each thread performing unique operation

process states

new: process creation running: instruction are being executed waiting: process is waiting on an event ready: process is in main memory waiting to be assigned to a processor terminated: process has finished execution

Threads vs processes

process has address space, program code, global variables, heap, stack, os resources thread is a single sequential execution stream within a process has registers, program counter, stack, stack pointer (other threads can access these but shouldn't)

User level threads

provide a library of functions to allow user processes to manage (create,delete,schedule) their own threads, os is not aware of these threads advantages: doesn't require modification to the os simple representation simple management (creating switching synching done without kernel) fast flexible cpu scheduling can be customized to suit the needs of the alg disadvantages lack of coordination between threads and so kernel, process as a whole gets one time slice, same time slice, whether process has one thread or 10000 also up to each thread to relinquish control to other threads in that process requires non-blocking system calls otherwise entire process will blcoked in the kernel, even if there are runnable threads left in the process

Operating system

A class of programs that make an intermediate layer between a user (application layer) of a computer and the computer hardware.

Types of system call pt 2

Communications create delete communication connection send, recieve messages if message passing model to host name or process name shared memory model create and ganin access to memory regions transfer status info attach and detach remote devices Protection control access to resources get and set permissions allow or deny access

Concurrency vs Parallelism

Concurrency on a single core system 123412341234 parallelism on a multi core system 131313 242424

Kernel vs User mode

Dual modes used to protect os and user. Some instruction designated as privileged only executable in kernel mode, system call changes mode to kernel, return from call rests it to user. Mode bit used to differentiate between modes Certain insturciton could be executed only when the cpu is in kernel mode hardware devices could be accessed only when the program is executing in kernel mode control over when interrupts could be enabled or disabled is also possible only when the cpu is in kernel mode cpu has very limited capability when executing in user mode, thereby enforcing protection of critical resources

Thread programming

Good programs to multithread gui (speedy response) server(access multi ind requests) os kernel repeditive numerical taks bad programs to multithread programs that don't have multi concurrent tasks multi task programs that requrie protection between tasks Threads are easy to switch between task contexts and coordinate between, threads are more intuitive to program, cheaper to create only need a stack and storage for registers, very little resources, context switches are fast, communications between threads is easy

4 components of a computer system

Hardware-provides basic computing resources, cpu,memory,i/o devices OS-controls and coordinates use of hardware among various applications and users Application programs-define the ways in which the system resources are used to solve the computing problems of the user Users-people,machines,other processes

Caching

Important principle performed at many levels in a computer(hardware,os,software) Processor speed faster than memory access speed Copy Data into faster memory Cache smaller than storage being caches, cache management important design problem, cache size and replacement policy, contains copy of a portion of main memory Cache checked first to determine if info is there, if present info used directly from cache,if not block of data copied to cache and used ther to exploit principle of locality Interacts with other memory management hardware Processor must access memory once per instruction cycle cache coherency problem all caches in a multiprocessor environment must have the same value data

Interrupt handling

Interrupt handling, os preserves state of cpu by storing registers and the program counter. polling-interrupt handler polls or sends signal to each device (in an order) to find who sent interrupt vectored-signal sent via the system bus informing interrupt handler that attention is required (has id of device that sent it) seperate segments of code determine what action should be taken for each type of interrupt

producer consumer problem

Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process unbounded buffer places no practical limit on the size of the buffer bounded buffer assumes that there is a fixed buffer size

OS services

UI- user interfae, varies between command line interfae, graphics user interface, batch Program execution- system must bhe able to load a program into memory and to run that program, end execution, either normally or abnormally (errors) i/o- a running program may require i/o, which may involve a file or an i/o device file system manipulation- the file system is of particular interest. Programs need to read and write files and directories, create and delete them, search them, list file information, permission management. communications- processes may exchange information, on the same computer or between computers over a network, communications may be via shared memory or through message passing (packets moved by the os) error detection- os needs to be constantly aware of possible errors, may occur in the cpu and memory hardware, in i/o devices, in user program, for each type of error, os should take the appropriate action to ensure correct and consistent computing, debugging facilities can greatly enhance the user's and programmers' abilitites to efficiently use the system resource sharing-os func for ensuring the efficient operation of the system itself via resource sharing, resource allocation- when multiple users or multiple jobs running concurrently, resources must be allocated to each of them, many types of resources-cpu cycles, main memory, file storage, i/o devices., accounting- to keep track of which users use how much and what kinds of computer resources, protection and security- owners of info stored in a multiuser or networked computer system may want to control use of that info, concurrent processes should not interfere with each other, protection involves ensuring that all access to system resources is controlled, security of the system from outsiders requires user authentication extends to defending external i/o devices from invalid access attempts

os design

User goals- os should be convenient to use, easy to learn, reliable, safe and fast System goals - os should be esy to maintain as well as flexible, error free and efficient Policy: What will be done? Mechanism: How to do it? OS made of mix of languages, lowest levels in assembly, main body in c, systems programs in c/c++. More high level code means os is more portable but also less efficient Emulation can allow an os to run on a non native hardware

Process

a program in execution, which forms the basis of all computation (must progress in sequential fashion) one program can be several processses

Timesharing

timesharing(multitasking) is logical extension in which cpu switches jobs so frequently that users can interact with each job while it is running, creating interactive computing,response time should be <1 sec, each user has at least one program executing in memory (process), if several jobs ready to run at the same time (cpu scheduling), if processes don't fit in memory, swapping moves them in and out to run, virtual memory allows execution of processes not completely in memory

Interrupts

Interrupt the normal sequencing of the processor. Provided to improve processor utilization (most i/o devices are slower than processor, processor must pause to wait for device). OS are interrupt driven, Interrupt transfers control to the interrupt service routing generally, through the interrupt vector, which contains the addresses of all the service routines. Interrupt architecture saves the address of the interrupted instruction. Same level interrupts are disabled while another interrupt is being processed. A trap is a software generated interrupt caused either by an error or a user request and occurs by executing a system call aka monitor call.

Queue

Job queue- set of all processes in the system Ready queue - set of all processes residing in main memory, ready and waiting to execute Device queue-set of processes waitng for an I/O device Processes migrate among various queues

Clustered Systems

Like multiprocessor systems, but multiple systems working together, usually sharing storage via a storage area network, provides a high-availability service which survives failures, asymmetric clustering has one machine in hot-standby mode, symmetric clustering has multiple nodes running applications, monitoring each other, some clusters are for high-performance computing applications must be written to use parallelization, some have distributed lock manager to avoid conflicting operations

Debugging

Log files Core dump files capturing memory of the process crash dump files containing kernel memory

3 multithreading models

Many to one many user threads mapped to a single kernel thread one thread blocking causes all to block multiple threads may not run in parallel on multicore system b/c only one may be in kernel at a time few systems use this model One to one each user thread maps to a kernel thread creating a user thread creates a kernel thread more concurrency than many to one number of threads per porcess sometimes restricted due to overhead Many to many models allows many user level threads to be mapped to many kernel threads allows the os to create a sufficient number of kernel threads two level model similar to mm except that is allows a user thread to be bound to kernel thread

Process scheduling

Maximizes cpu usage, process scheduler selects among available processes for next execution on cpu

Multiprogramming

Multiprog(batch system)needed for efficiency,single user cannot keep cpu and i/o devices busy at all times,multiprog organizes jobs (code and data) so cpu always has one to execute, subset of total jobs in system is kept in memory, one job selected and run via job scheduling, when it has to wait os switches to another job

Multiprogramming and time sharing goals

Multiprogramming goal- have some process running at all times Time sharing goal- switch the cpu among processes so frequently that users can interact with each program while its running Both require a scheduler

Client Server vs P2p system

P2P does not distinguish clients and servers, instead all nodes are considered peers, may each act as client, server or both, node must join p2p network, registers its service with central lookup service on network, broadcast request for service and respond to requests for service via discovery protocol Client server model distinguishes the roles of the client and server

Creating processes

Parent process create children processes, which in turn create other processes, forming a tree of processes Processes id'd and managed via a process identifier (pid) Resource sharing options parent and children share resources children share subset of parent's resources (prevents any process from overloading teh system by creating too many children processes) or parent and children share no resources Execution options parent and children execute concurrently parent waits until children terminate then parent executes Address space child duplicate of parent child has program loaded into it (example fork)

Types of system calls

Process control- create process, terminate process end, abort load, execute get process attributes, set attributes wait for time wait event, signal event allocate and free memory dump memory if error Debugger for determing bugs, single step execution Locks for managing access to shared data between processses File management create file, delete file open, close file read, write , reposition get and set file attributes Device management request device, release device read, write , reposition get device attributes, set attributes logically attach or detach devices Info Maintenance get time or date, set time or date get system data, set system data get and set process, file or attributes

Thread pools

Process creates a multitude of threads and stores them in a pool where they await work advantages usually slightly fster to service a request with an existing thread than create a new thread allows the number of threads in the applications to be bound to the size of the pool seperating task to be performed from mechanics of creating task allow sdifferent strategies for running task

Destroying processes

Process executes last statement and then asks the os to delete it using the exit() system call returns data from child to parent via (wait()) process resources are deallocated by os Parent may terminate the exectuion of children processes using the abort() system call. Some reasons for doing so child has exceeded allocated resources task assigned to child is no longer required parent is exiting and the os does not allow a child to continue if its parent terminates Some os do not allow child to exist if its parent has terminated. If a process terminates, then all its children must be terminated cascading termination, all children grand children terminated, termination is initiated by the os Tthe parent process may wait for termination of a child process by using the wait() system call. It returns status info and pid of teh terminated process pid = wait(&status); if no parent waiting process is a zombie if parent terminated without invoking wait process is an orphan

Type of interrupts

Program-generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute and illegal machine instruction, and reference outside a user's allowed memory space. Timer-Generated by a timer within the processor. This allows the os to perform certain functions on a regular basis. I/O-generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions. Hardware failure-Generated by a failure,such as power failure or memory parity error.

system calls

Programming interface to the services provided by the OS Typically written in a high-level lang Mostly accessed by programs via a high level api rather than direct system call use Typically a number associated with each system call, system call interface maintains a table indexed according to these numbers The system call interface invokes the intended system call in the OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented, just needs to obey api and understad what os will do as a result call, Most details of os interface hidden from programmer by api, managed by run time support library OFten more info is required than simply identify of desired system call, exact type and amount of info vary according to os and call 3 general methods used to pass parameters to the os, pass the parameters in the registers, parameters stored in a block, or table, in memory and address of block passed as a parameter in a register, parameters placed or pushed onto the stack by the program and popped off the stack by the os, block and stack methods do not limit the number or length of paramters being passed

Process Switching

Save state of process 1, reload state of process 2, interrupt/system call, save state of process 2, reload state of process 1

threading issues

Semantics of fork() and exec() system calls fork() duplicate only calling thread or all threads? exec() usually works replace running process including all threads signal handling-how to notify process that an event occured. synchronous signal-delivered to same process that performed the operation that caused the signal asynchronous-when signal is generated by an event external to a running process (ctrl +c to kill a process) Thread cancellation of target thread asynchronous cancellations terminates the target thread immediately may not relinquish resources properly defered cancellation allows the target thread to periodically check if it should be cancelled Thread local storage allows each thread to have its own copy of certain data Scheduler activations

2 models of IPC

Shared memory Message passing

Schedulers

Short term scheduler (cpu scheduler)- selects which process should be executed next and allocates cpu, can be the only scheduler in a system, invoked frequently Long-term scheduler(job scheduler)-selects which processes should be brought into the ready queue, invoked infrequently,controls the degree of multiprogramming Processes can be described as either I/O bound process spends more time doing I/O than computations, many short cpu bursts CPU bound process spends more time doing computations few very long CPU bursts Long term scheduler strives for good process mix Medium term scheduler can be added if the degree of multiprogramming needs to decrease,removes process from memory, stores it on disk, bring back from disk to continue execution

os structures

Simple Structure - MS-DOS Written to provdie the most functionability in the least space, not divided into modules, UNIX- limited by hardware functionality, modern os has two parts, systems programs, the kernel ( consists of sytem call interface and above the physical hardware, provides file system, cpu scheduling, memory management, and other funcs) Layered Approach- os is divided into a number of layers each built on top of a lower layer. Bottom layer is the hardware Microkernel sytem structure- communication takes place betwen user modules using message passing, benefits easier to extend a microkernel, easier to port, reliable, secure, cons performance overhead of user space to kernel space communication Modules- uses ooa, each core component is seperate, each talks to others over known interfaces, each is loadable as needed within the kernel, similar to layers but more flexible (linux)

Storage Structures

Speed and cost increases as you go up this list, capacity increases as you go down Volatile : registers cache main memory Non-volatile: ssd hard disk optical disk magnetic tapes

Multiproccesing

aka parallel systems, tightly-coupled systems growing in use and importance advantages-increased throughput-although not multiplied by # or processors due to overhead, resource contention, economy of scale due to sharing mass storage, peripherals and power supply, increased reliability-graceful degradation or fault tolerance, if 1 processor fails, system does not halt

Asymmetric multiproc vs symmetric multproc

asymmetric-each processor is assigned a specific task by the "boss" processor symmetric - each processor performs all/same tasks processors are peers

Kernel level threads

provides system calls to create and manage threads advantages kernel has full knowledge of all threads-scheduler may choose to give a process with 10 threads more time than process with only 1 thread good for applications that frequently block (server processes with frequent interprocess communication) disadvantages slower - thread operations are significantly slower than for user level threads significant overhead and increased kernel complexity - kernel must manage and schedule threads as well as processes - requires a full thread control block for each thread

Process Control Block (PCB)

serves as the repository for any information that may vary from process to process; contains information associated with each process (aka task control block) Process state Program counter CPU registers Cpu scheduling information Memory management information Accounting information I/O status

Context switch

stopping one process and starting another, switches when cpu saves one state and then loads another Context of a process represented in the PCB Context switch time is overhead the system does no useful work while switching Time dependent on hardware support

context

the entire state of the process at any instant, program code, data section, heap, procedure call stack, register contents, os resources in use


Conjuntos de estudio relacionados

ECON 3023 Midterm Exam 3 - Kazianga

View Set

CH 20: Corporations and Partnerships

View Set

Prologue from The Canterbury Tales

View Set

struggle (im literally gonna fall asleep rn)

View Set