351 midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Short term scheduler

(CPU scheduler) - selects which process should be executed next and allocates CPU Sometimes the only scheduler in a system Short-term scheduler is invoked frequently (milliseconds) Þ (must be fast)

Long term scheduler

(or job scheduler) - selects which processes should be brought into the ready queue Long-term scheduler is invoked infrequently (seconds, minutes) (may be slow) The long-term scheduler controls the degree of multiprogramming

Monitor

A high-level language synchronization construct that protects variables from race conditions. monitor uses condition variables that allow processes to wait for certain conditions to become true and to signal one another when conditions have been set to true. a programming language construct encapsulating a set of programmer-defined: Operations (i.e. functions), and Shared data on which the operations operate. Operations inside the monitor can only access the variables inside the monitor. Only one process at a time can execute in monitor

Zombie process

A process that has terminated, but whose parent has not yet called wait()

What is an operating system? What services does it provide?

A program that: Runs at all times (a.k.a. a resident monitor, a.k.a. kernel) Manages computer's hardware resources. Provides basis for application programs. Acts as an intermediary between user and hardware. No completely adequate definition. It provides the means for proper use of system resources e.g. hardware, software, and data.

Readers writers problem

A shared database. Two sets of processes: Readers: only want to read the database. Writers: may read or modify the database. Readers should not be waiting for other readers. no reader shall be kept waiting if the database is currently opened for reading.

Socket vs pipe

A socket is defined as an endpoint for communication. Interface for network i/o A pipe is a logical conduit allowing two processes to communicate. Ordinary pipes - cannot be accessed from outside the process that created it. Typically, a parent process creates a pipe and uses it to communicate with a child process. Named pipes - can be accessed without a parent-child relationship.

Changing process state

As a program executes, it changes state. State depends on current activity. An interrupt can cause a process to change states

Petersons solution

Assume two processes pi pj. Assume LOAD and STORE are atomic. Two processes share the following variables: int turn; bool flag[2] turn: indicates whose turn it is to enter the critical section. flag: indicates if a process is ready to enter the critical section. flag[i] = true implies that process Pi is ready to enter it's critical section The two processes (Pi and Pj) share the following variables: int turn: whose turn it is to enter the critical section? bool flag[2]: if a process is ready to enter the critical section? flag[i] = true implies that process Pi is ready! Process Pi sets flag[i] to true, indicating that it's ready to enter it's critical section. Process Pi sets turn to j, indicating that Pj may enter its critical section if it wishes to do so. If both processes try to enter their critical sections at the same time, then turn will be set to both i and j at roughly the same time. The final value if turn will be determined by the process that gets to update turn last, thus preventing both processes from entering their critical section simultaneously. Not practical today for the primary reason that, to improve system performance, processors and/or compilers may reorder read and write operations that have no dependencies

Thread

Basic unit of CPU utilization A program counter: keeps track of which instruction to execute next. Register values: store the current working variables. Stack: keeps track of the program execution history.

What is the difference between direct and indirect message passing?

Direct communication - Processes must name each other explicitly. send (P, message) - send a message to process P receive(Q, message) - receive a message from process Q Links are established automatically A link is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi-directional Indirect communication - Messages are directed and received from mailboxes (also referred to as ports) Properties of communication link: Link established only if processes share a common mailbox A link may be associated with many processes Each pair of processes may share several communication links Link may be unidirectional or bi-directional

Process control block

Information associated with each process (also called task control block) Process state - running, waiting, etc Program counter - location of instruction to next execute CPU registers - contents of all process-centric registers CPU scheduling information- priorities, scheduling queue pointers Memory-management information - memory allocated to the process Accounting information - CPU used, clock time elapsed since start, time limits I/O status information - I/O devices allocated to process, list of open files

• What are different types of cloud computing services?

Infrastructure-as-a-Service (IaaS): provides hardware resources e.g. storage, CPU, and networking services. Platform-as-a-Service (PaaS): provides hardware and platform ready for applications (e.g. a database server). Software-as-a-Service (SaaS): provides software applications over the network.

• What is the job of OS with respect to memory management?

Keep track of what parts of memory are being used by what processes. Decide which processes (or parts of) to move into and out of memory. Allocate and deallocate memory as needed. Work with main memory - A large array of bytes or words where each word or byte has its own address

Many-to-One Model

Many user-level threads are mapped to a single kernel thread. User-level library manages the threads - efficient. If one user-level thread makes a system call, then all threads block while the system call is serviced. Threads cannot run concurrently on multiple processors.

One-to-one

Maps a single user thread to a single kernel thread. Other threads can continue execution even if one thread blocks on a system call. Multiple threads run in parallel on multiprocessors. Enables concurrent execution of threads on multiple cores. The overhead of creating kernel threads is high. Maximum number of threads is usually limited (too many threads many burden the application performance).

Deadlock

Multiple processes waiting indefinitely for an event that can be triggered by only one of the waiting processes. When using semaphores with a waiting queue, may result in a situation where two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes. The event is the signal() operation. Processes are deadlocked when every process in the set is waiting for an event that can be caused only by another process in the set.

Many-to-many

Multiplexes many user-level to many kernel-level threads. Two types of user threads: Bound: mapped to a single kernel thread. Unbound: multiple may be mapped to the same kernel thread. Only the caller thread blocks on a blocking system call. Enables threads to run concurrently on multiple processors.

Multiprogramming

Multiprogramming increases CPU utilization, as well as keeping users satisfied, by organizing programs so that the CPU always has one to execute. In a multiprogrammed system, a program in execution is termed a process.

Atomic

Non interruptable. Once it starts, always completes.

What are the advantages of using multiple processes instead of multiple threads?

Not as challenging to use compared to multiple threads. Easier to test and debug.

Which model has true parallelism?

One-to-one

What does a child inherit from parent?

Parent and children share all resources Children share subset of parent's resources Parent and child share no resources

Orphan process

Parent terminated without invoking wait()

What is the difference between pipes, shared memory, message passing, for IPC?

Pipe - Acts as a conduit allowing two processes to communicate Shared memory - An area of memory shared among the processes that wish to communicate. Communication under control of the users processes. Message passing - Mechanism for processes to communicate and to synchronize their actions. Message system - processes communicate with each other without resorting to shared variables

IPC (interprocess communication )

Processes within a system may be independent or cooperating.Cooperating process can affect or be affected by other processes, including sharing data Cooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data— that is, send data to and receive data from each other. Two models - shared memory and message passing. In the shared-memory model, a region of memory that is shared by the cooperating processes is established. Processes can then exchange information by reading and writing data to the shared region. Major issues is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory With message passing,communication takes place by means of messages exchanged between the cooperating processes.

What is the difference between a program and a process?

Program: is a set of instructions (a passive entity). Process: a program in execution (an active entity). Process: a unit of work on the system

What are advantages and drawbacks of cloud computing?

Pros: Helps reduce operating costs. Helps to improve resource utilization (by combining computing resources). Makes it easier to tackle large scale computing problems.

• What are protection and security?

Protection: controls the access of users and processes to the system resources (e.g. memory, files, etc). Internal to the OS. Example: process A attempts to (illegally) write to the memory of process B. The operating system detects the violation and terminates process A. Security: defending the OS against external threats. Example: malware (e.g. viruses, worms, etc).

Types of cloud

Public: available to anybody willing to pay for the services. Example: Amazon's Elastic Cloud (EC2) Example: Google's App Engine Private: a cloud run by a company for its own use. Example: IBM SmartCloud Foundation Hybrid: a combination of public and private.

Benefits of multithreading

Responsiveness: multithreaded application may continue running even if a part of the program is busy or blocked. Resource Sharing: all threads of a process share memory and resources. Economy: creating and managing a thread is faster than creating and managing a process. Most resources do not need to be cloned. Thread context switch is faster than a process context switch,. Scalability: multiple threads can execute in parallel on multiple processors.

How are threads affected by signals?

Signal handling options in multithreaded processes: - Deliver the signal to the thread to which the signal applies. - Deliver the signal to every thread in the process. - Deliver the signal to certain threads in the process. - Assign a specific thread to receive all signals for the process.

Semaphore

Specialized integer variable S, accessible only through wait() and signal() operations. All modifications to S are atomic

How is process memory structured

Stack containing temporary data Data section containing global variables Heap containing memory dynamically allocated during run time

Hypervisors

The computer function that manages the virtual machine; also called a virtual machine manager (VMM). type 0 hypervisor A hardware-based virtualization solution that provides support for virtual machine creation and management via fi rmware (e.g., IBM LPARs and Oracle LDOMs). type 1 hypervisor Operating-system-like software built to provide virtualization (e.g., VMware ESX, Joyent SmartOS and Citrix Xenserver). type 2 hypervisor An application that runs on standard operating systems but provides virtual machine management features to guest operating systems (e.g., VMware

Binary semaphore

The value can range only between 0 and 1. Also known as mutex (i.e. mutual exclusion) locks. The mutex is initialized to 1.

Counting Semaphore

The value is unrestricted. Useful for coordinating access to a resource with finite number of instances. The semaphore is initialized to the maximum # of instances

What resources do threads within a process share?

Threads belonging to a process share the data of the process.

Virtualization

Virtualization is a technology that allows us to abstract the hardware of a single computer (the CPU, memory, disk drives, network interface cards, and so forth) into several different execution environments, thereby creating the illusion that each separate environment is running on its own private computer.

Context switch

When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch Represented in PCB §Context-switch time is overhead; the system does no useful work while switching §The more complex the OS and the PCB, the longer the context switch Time dependent on hardware support

What are the benefits of using threads over using processes?

You can get parallelism - multiple threads are making progress simutaneously. Concurrency - Multiple threads making progress. Single system cpu - concurrency only. Parallelism requires multicore system with many cpus

Critical section

a segment of process code, in which the process modifies shared resources e.g. updating a table or writing to a file. No two processes may execute in the critical section at the same time e.g. no two processes may update the same variable at the same time.

Multithreading

allowing a process to have multiple parallel threads of execution. : if process has multiple threads, it can perform multiple tasks at a time. Example: a Web server is accessed by thousands of clients simultaneously. How can we service the clients? Multithreading: within the same server process, create a separate thread for each client. Parallelism without the overheads of resource duplication.

Medium term scheduler -

can be added if degree of multiple programming needs to decrease. Remove process from memory, store on disk, bring back in from disk to continue execution: swapping

Thread Pool

create a number of threads and place them into the pool, where they sit and wait for work. When a work request comes in, a thread from the pool services the request and returns to the pool. Advantages: Servicing a request with an existing thread is usually faster than waiting to create a new thread. A thread pool limits the number of threads that exist at any one point - i.e. prevents resource exhaustion.

Process synchronization

ensuring an orderly execution of cooperating processes that share data, in order to maintain data consistency. Coordination of access to data by two or more threads or processes.

Critical section problem

ensuring that only one process is executing in its critical section. solution to the critical-section problem must satisfy the following three requirements: (1) mutual exclusion, (2) progress, and (3) bounded waiting. Mutual exclusion ensures that only one process at a time is active in its critical section. Progress ensures that programs will cooperatively determine what process will next enter its critical section. Bounded waiting limits how much time a program will wait before it can enter its critical section.

How does the OS help manage I/O (i.e. device queues, etc.)?

hide the peculiarities of specific devices from the user. the Unix I/O subsystem provides: 1 Functionality to manage data buffering, caching, and spooling. 2 A general device driver interface. 3 Drivers for specific hardware devices (which know how to control the specific device).

Process states

new: The process is being created running: Instructions are being executed waiting: The process is waiting for some event to occur ready: The process is waiting to be assigned to a processor terminated: The process has finished execution

Semaphore misuse

no method defined in this interface for getting the value of the internal counter, and no such method is expected to be provided in any implementing class

Be able to illustrate how different interleavings of instructions from two processes that share data, can produce in inconsistent results.

p264 As you will see in the following sections, the only way to preserve mutual exclusion is by using proper synchronization tools.

What is caching? What is cache coherence problem?

temporarily store data/instructions in faster storage (i.e. cache) and access them from there. Must ensure data consistency along all levels of the hierarchy.

Signal

used in Unix to notify a process that a particular event has occurred. synchronous or asynchronous: Synchronous: signal resulting from the process operations. e.g. illegal memory access or division by 0. Asynchronous: signal generated by the event outside of the process. e.g. user pressing <Ctrl+C>.

Race condition

when multiple processes (or threads) access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place. a situation in which two threads are concurrently trying to change the value of a variable. Possible race condition may occur.

Why use monitor over sempahore

x.signal() in monitor resumes exactly one suspended process. process. If no process is suspended, then the signal() operation has no effect; that is, the state of x is the same as if the operation had never been executed (Figure 6.13). Contrast this operation with the signal() operation associated with semaphores, which always affects the state of the semaphore


Ensembles d'études connexes

Real Estate Principles Final Exam

View Set

Clin Pharm: Intro, Rheum, EENT, GI, ID, Behavioral Health, Endo, Derm, OB/GYN, Neuro, Fluids/Electrolytes, Pulm, Peds, Cardio/Hemo, Pain Manangment

View Set

Consumer Behavior Chp 16 (Exam 2)

View Set