Study sets, textbooks, questions
Upgrade to remove ads
Chapter 2 CIS 345 Operating Systems
Terms in this set (85)
All the runnable software on the computer, sometimes including the operating system, is organized into a number of sequential processes, or just processes for short. A process is just an instance of an executing program, including the current values of the program counter, registers, and variables
The real CPU switches back and forth from process to process, but to understand the system, it is much easier to think about a collection of processes running in (pseudo) parallel than to try to keep track of how the CPU switches from program to program. This rapid switching back and forth is called multiprogramming.
Another background process may be designed to accept incoming requests for Web pages hosted on that machine, waking up when a request arrives to service the request. Processes that stay in the background to handle some activity such as email, Web pages, news, printing, and so on are called daemons
In UNIX, there is only one system call to create a new process: fork. This call creates an exact clone of the calling process. After the fork, the two processes, the parent and the child, have the same memory image, the same environment strings, and the same open files.
Usually, the child process then executes execve or a similar system call to change its memory image and run a new program.
handles both process creation and loading the correct program into the new process.
Alternatively, the child may share all of the parent's memory, but in that case the memory is shared copy-on-write, which means that whenever either of the two wants to modify part of the memory, that chunk of memory is explicitly copied first to make sure the modification occurs in a private memory area.
The only hint of a process hierarchy is that when a process is created, the parent is given a special token (called a handle).
Running process state
actually using the CPU at that instant
Ready process state
runnable; temporarily stopped to let another process run
Blocked process state
unable to run until some external event happens
A block of information in main memory
process control blocks
Entries in a process table. This entry contains important information about the process' state, including its program counter, stack pointer, memory allocation, the status of its open files, its accounting and scheduling information, and everything else about the process that must be saved when the process is switched from running to ready or blocked state so that it can be restarted later as if it had never been stopped.
Associated with each I/O class is a location (typically at a fixed location near the bottom of memory)
degree of multiprogramming
CPU Utilization = 1 - p^n
Separate, independent tasks within a job. The main reason for having threads is that in many applications, multiple activities are going on at once. A second argument for having threads is that since they are lighter weight than processes, they are easier (i.e. faster) to create and destroy than processes. A third reason for having threads is also a performance argument. Threads yield no performance gain when all of them are CPU bound, but when there is substantial computing and also substantial I/O, having threads allows these activities to overlap, thus speeding up the application.
A collection of heavily used pages in main memory to eliminate the need to go to disk to get them.
A thread, reads incoming requests for work from the network. After examining the request, it chooses an idle (i.e. blocked) worker thread and hands it the request, possibly by writing a pointer to the message into a special word associated with each thread.
Finite state machine
A design like this, in which each computation has a saved state, and there exists some set of events that can occur to change the state
The other concept of a process is a thread of execution, usually shortened to just thread. The thread has a program counter that keeps track of which instruction to execute next. It has registers, which hold its current working variables. It has a stack, which contains the execution history, with one frame for each procedure called but not yet returned from.
Because threads have some of the properties of processes, they are sometimes called lightweight processes.
A term used to describe the situation of allowing multiple threads in the same process.
A parameter to thread_create specifies the name of a procedure for the new thread to run. It is not necessary (or even possible) to specify anything about the new thread's address space, since it automatically runs in the adress space of the creating thread.
When a thread has finished its work, it can exit by calling a library procedure say, thread_exit. It then vanishes and is no longer schedulable. In some thread systems, one thread can wait of a (specific) thread to exit by calling a procedure for example thread_join
Allows a thread to voluntarily give up the CPU to let another thread run. Such a call is important because there is no clock interrupt to actually enforce multiprogramming as there is with processes. Thus it is important for threads to be polite and voluntarily surrender the CPU from time to time to give other threads a chance to run.
A new thread is created using the pthread_create call. The thread identifier of the newly created thread is returned as the function value. This call is intentionally very much like the fork system call (except with parameters), with the thread identifier playing the role of the PID, mostly for identifying threads referenced in other calls.
When a thread has finished the work it has been assigned, it can terminate by calling pthread_exit. This call stops the thread and releases its stack.
The thread that is waiting calls pthread_join to wait for a specific other thread to terminate.
Sometimes it happens that a thread is not logically blocked, but feels that is has run long enough and wants to give another thread a chance to run. It can accomplish this goal by calling pthread_yield.
creates the attribute structure associated with a thread and initializes it to the default values. These values (such as the priority) can be changed by manipulating fields in the attribute structure.
removes a thread's attribute structure, freeing up its memory
When threads are managed in user space, each process needs its own private thread table to keep track of the threads in that process.
When a thread is finished running for the moment, for example, when it calls thread_yield, the code of thread_yield can save the thread's information in the thread table itself.
select system call (Unix)
Allows the called to tell whether a prospective read will block. When this call is present, the library procedure read can be replaced with a new one that first does a select call and then does the read call only if its safe (i.e. will not block). If the read call will block, the call is not made.
Jack or wrapper
The code placed around the system call to do the checking is called a jacket or wrapper.
When a thread wants to create a new thread or destroy an existing thread, it makes a kernel call, which then does the creation or destruction by updating the kernel thread table.
kernel's thread table
holds each thread's registers, state, and other information
Thread blocks (kernel)
When a thread blocks, the kernel at its option, can run either another thread from the same process (if one is ready) or a thread from a different process.
Thread is destroyed (kernel)
When a thread is destroyed, it is marked as not runnable, but its kernel data structures are not otherwise affected. Later, when a new thread must be created, an old thread is reactivated, saving some overhead. Thread recycling is also possible for user-level threads, but since the thread-management overhead is much smaller, there is less incentive to do this.
The goals of the scheduler activation work are to mimic the functionality of kernel threads, but with the better performance and greater flexibility usually associated with threads packages implemented in user space. When scheduler activations are used, the kernel assigns a certain number of virtual processors to each process and lets the (user-space) run-time system allocate threads to processors. The number of virtual processors allocated to a process is initially one, but the process can ask for more and can also return processors it no longer needs.
The notification happens by having the kernel activate the run-time system at a known starting address, roughly analogous to a signal in UNIX. This mechanism is called an upcall.
However, a completely different approach is also possible, in which the arrival of a message causes the system to create a new thread to handle the message. Such a thread is called a pop-up thread. A key advantage of pop-up threads is that since they are brand new, they do not have any history-- registers, stack, whatever- that must be restored. Each one starts out fresh and each one is identical to all the others.
How processes communicate. There are three issues. The first was alluded to above: how one process can pass information to another. The second has to do with making sure two or more processes do not get in each other's way, for example, two processes in an airline reservation system each trying to grab the last seat on a -plane for a different customer. The third concerns proper sequencing when dependencies are present: if process A produces data and process B prints them, B has to wait until A has produced some data before starting to print.
When a process wants to print a file, it enters the file name in a special spooler directory.
Periodically checks to see if there are any files to be printed, and if there are, it prints them and then removes their names form the directory.
Where two or more processes are reading or writing some shared data and the final result depends on who runs precisely when are called race conditions
To prohibit more than one process from reading and writing the shared data at the same time. Put in other words, what we need is mutual exclusion, that is some way of making sure that if one process is using a shared variable or file, the other processes will be excluded from doing the same thing.
Critical region or critical section
That part of the program where the shared memory is accessed is called the critical region or critical section. If we could arrange matters such that no two processes were ever in their critical regions at the same time.
Continuously testing a variable until some value appears is called busy waiting.
It should usually be avoided, since it wastes CPU time. Only when there is a reasonable expectation that the wait will be short is busy waiting used. A lock that is uses busy waiting is called a spin lock.
producer consumer problem
Two processes share a common, fixed-size buffer. One of them, the producer, puts information into the buffer, and the other one, the consumer, takes it out.
To keep track of the number of items in the buffer, we will need a variable, count. If the maximum number of items the buffer can hold is N, the producer's code will first test to see if count is N.
wakeup waiting bit
A quick fix is to modify the rules to add a wakeup waiting bit to the picture. When a wakeup is sent to a process that is still awake, this bit is set. Later, when the process tries to go to sleep, if the wakeup waiting bit is on, it will be turned off, but the process will stay awake.
In his proposal, a new variable type, which he called a semaphore, was introduced. A semaphore could have the value 0, indicating that no wakeups were saved, or some positive value if one or more wakeups were pending.
The down operation on a semaphore checks to see if the value is greater than 0. If so, it decrements the value (i. e., uses up one stored wakeup) and just continues. If the value is 0, the process is put to sleep without completing the down for the moment.
Checking the value, changing it, and possibly going to sleep, are all done as a single indivisible atomic action.
up semaphore operation
The up operation increments the value of the semaphore addressed.
Semaphores that are initialized to 1 and used by two or more processes to ensure that only one of them can enter its critical region at the same time are called binary semaphores.
The other use of semaphores is for synchronization. The full and empty semaphores are needed to guarantee that certain even sequences do or do not occur.
A mutex is a shared variable that can be in one of two states unlocked or locked.
When a thread (or process) needs access to a critical region, it calls mutex_lock.
A futex is a feature of Linux that implements basic locking (much like a mutex) but avoids dropping into the kernel unless it really has to. Since switching to the kernel and back is quite expensive, doing so improves performance considerably. A futex consists of two parts: a kernel service and a user library. The kernel service provides a "wait queue" that allows multiple processes to wait on a lock. They will not run, unless the kernel explicitly unlocks them.
A monitor is a collection of procedures, variables, and data structures that are all grouped together in a special kind of module or package. Processes may call the procedures in a monitor whenever they want to, but they cannot directly access the monitor's internal data structures from procedures declared outside the monitor.
similar to signals but designed to work at the tread level in conjunction w/ mutex to avoid need for busy waiting, what is required for a monitor
This method of interprocess communication uses two primitives, send and receive, which, like semaphores and unlike monitors, are system calls rather than language constructs.
To guard against lost messages, the sender and receiver can agree that as soon as a message has been received, the receiver will send back a special acknowledgement message.
Authentication is also an issue in message systems: how can the client tell that it is communicating with the real file server, and not with an imposter?
One way is to assign each process a unique address and have messages be addressed to processes. A different way is to invent a new data structure, called a mailbox. A mailbox is a place to buffer a certain number of message, typically specified when the mailbox is created. When mailboxes are used, the address parameters in the send and receive calls are mailboxes, not processes.
When a process reaches the barrier, it is blocked until all processes have reached the barrier.
RCU (Read Copy-Update)
The main reason that the removal of B and D works without locking the data structure, is that RCU, decouples the removal and reclamation phases of the update.
read-side critical section
Specifically, readers access the data structure in what is known as a read-side critical section which may contain any code, a s long as it does not block or sleep.
In that case, we know the maximum time we need to wait. Specifically, we define a grace period as any time period in which we know that each thread to be outside the read-side critical section at least once.
The part of the operating system that makes the choice is called the scheduler and the algorithm it uses is called the scheduling algorithm
compute-bound or CPU-bound
Computer-bound processes typically have long CPU bursts and thus infrequent I/O waits, whereas I/O-bound processes have short CPU bursts and thus frequent I/O waits. Note that the key factor is the length of the CPU burst, not the length of the I/O bursts. I/O bound processes are I/O bound because they do not compute much between I/O requests, not because they have especially long I/O requests.
A nonpreemptive scheduling algorithm picks a process to run and then just lets it run until it blocks (either on I/O or waiting for another process) or voluntarily releases the CPU.
a preemptive scheduling algorithm picks a process and lets it run for a maximum of some fixed time.
is the number of jobs per hour that the system completes. All things considered, finishing 50 jobs per hour is better than finishing 40 jobs per hour
the statistically average time from the moment that a batch job is submitted until the moment it is completed.
The time between issuing a command and getting a result
Processes are assigned the CPU in the order they request it.
shortest job first
When several equally important jobs are sitting in the input queue waiting to be started, the scheduler picks the shortest job first.
shortest remaining time net.
With this algorithm, the scheduler always chooses the process whose remaining run time is the shortest.
Each process is assigned a time interval, called its quantum, during which it is allowed to run. If the process is still running at the end of the quantum, the CPU is preempted and given to another process. If the process has blocked or finished before the quantum has elapsed, the CPU switching is done when the process blocks, of course. Round robin is easy to implement.
Each process is assigned a priority, and the runnable process with the highest priority is allowed to run.
The basic idea is to give processes lottery tickets for various system resources, such as CPU time. Whenever a scheduling decision has to be made, a lottery ticket is chosen at random, and the process holding that ticket gets the resource.
Students also viewed
Chapter 7, Chapter 9- Virtualization, Security
Module 5: Installing and configuring Hyper-V and v…
CS170 02 Processes and Threads
Other sets by this creator
Chapter 1 Introduction
CIS 345 Operating Systems Summer class Chapter 3
Chapter 6 Deadlocks Vocabulary
CIS 345 Operating Systems Chapter 1 Vocabulary
Suppose that you are given a sequence of n elements to sort. The input sequence consists of n/k subsequences, each containing k elements. The elements in a given subsequence are all smaller than the elements in the succeeding subsequence and larger than the elements in the preceding subsequence. Thus, all that is needed to sort the whole sequence of length n is to sort the k elements in each of the n/k subsequences. Show an Ω(n lg k) lower bound on the number of comparisons needed to solve this variant of the sorting problem. (Hint: It is not rigorous to simply combine the lower bounds for the individual subsequences.)
Suppose that we have a general linear program with n variables and m constraints, and suppose that we convert it into standard form. Give an upper bound on the number of variables and constraints in the resulting linear program.
How is a Frame widget used to organize other widgets?
Show how to sort n integers in the range 0 to n³ - 1 in O(n) time.
Recommended textbook solutions
Fundamentals of Database Systems
Ramez Elmasri, Shamkant B. Navathe
Information Technology Project Management: Providing Measurable Organizational Value
Jack T. Marchewka
Introduction to Algorithms
Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
Information Technology Project Management: Providing Measurable Organizational Value
Jack T. Marchewka
Other Quizlet sets
CH Exam 3