OS-Chapter 3

Ace your homework & exams now with Quizwiz!

What are the information of the task control block?

1.Process State 2.Program counter - location of the instruction to the next execute 3.CPU registers-contents of all process-centric registers 4.CPU scheduling information - priorities, scheduling queue pointers 5.Memory management information - memory allocated to the process 6.I/O status information - I/O devices allocated to process, list of open files 7.Accounting information - the amount of CPU and real time used, time limits, account numbers

What are the two models of IPC?

1.Shared memory 2.Message passing

What are the part of process in memory?

1.Stack(containing temporary data) 2.Heap (memory dynamically allocated during run time) 3.Data section(containing global variables) 4.Text section(program code) 5.Program counter

What do the two processes need to do if they want to communicate?

1.establish a communication link between them 2.exchange message via send/receive Processes must name each other explicitly.

What are the queues of processes?

1.job queue - set of all processes in the system 2.ready queue - set off all processes residing in main memory, ready and waiting to be executed 3.Device queues - set of processes waiting for an I/O device

What are the states of a process? (see pic. at slide 3.5)

1.new- the process is being created 2.running - instructions are being executed 3.waiting - the process is waiting for some event to occur 4.ready - the process is waiting to be assigned to a processor 5.terminated - the process has finished execution Only one process can be running on any process at any instant but many process may be ready and waiting.

What are the properties of blocking?

Blocking is considered synchronous Blocking send has the sender block until the message is received Blocking receive has the receiver block until a message is available

What are the differences between a cooperating process and a independent process?

Cooperating process can affect or be affected by other processes including sharing data. Independent process cannot affect or be affected by the execution of another process

Explain processes on a tree creation.(see pic.3.15)

Pid provides a unique value for each process in the system. The init process(which always has a pid=1) serves as the root parent process for all user processes. The children of init—kthreadd, sshd and login. The kthreadd process is responsible for creating additional processes that perform tasks on behalf of the kernel. The sshd process is responsible for managing clients that connect to the system by using ssh . The login process is responsible for managing clients that directly log onto the system.

What is a task control block?

Task control block are information associated with each process.

What are the properties of non-blocking?

Non-blocking is considered asynchronous Non-blocking send has the sender send the message and continue Non-blocking receive has the receiver receive a valid message or null

Wht do parents terminate execution of children processes?

Parent may terminate execution of children processes (abort()) 1. Child has exceeded allocated resources 2. Task assigned to child is no longer required 3. If parent is exiting a.Some operating systems do not allow child to continue if its parent terminates b.All children terminated - cascading termination

How is the process creation done?

Parent process create children processes, which, in turn create other processes, forming a tree of processes. Generally, process identified and managed via a process identifier (pid).

What do cooperating processes need?

They need interprocess communication(IPC)

What does process schedulers do?

They select among available processes for the next execution on CPU and maintain scheduling queues of processes.

Explain how the ready queues work.

This queue is generally stored as a linked list. A ready-queue header contains pointers to the first and final PCBs in the list. Each PCB includes a pointer field that points to the next PCB in the ready queue.

How to establish an indirect communication?

create a new mailbox send and receive messages through mailbox destroy a mailbox

Explain the C program for creating a separate process using the UNIX fork().

int main() { pid t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ execlp("/bin/ls","ls",NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; }

Write the C code of synchronization process.

message next_produced; while (true) { send(next_produced); } message next_consumed; while (true) { receive(next_consumed); }

What are the two address possibilities for the new process?

1. The child process is a duplicate of the parent process. 2. The child process has a new program loaded into it.

How is buffering implemented?

1. Zero capacity - 0 messages. Sender must wait for receiver. 2. Bounded capacity - finite length of n messages.Sender must wait if link full. 3. Unbounded capacity - infinite length.Sender never waits.

What are the two operations that interprocess communication offers?

1. send - message fixed or variables 2.receive

What are the information that are consumed by a consumer process?

1. unbounded-buffer places no practical limit on the size of the buffer 2.bounded-buffer assumes that there is a fixed buffer size

What are the disadvantages of the context switch?

1.Context-switch time is overhead; the system does no useful work while switching. The more complex the OS and the PCB -> longer the context switch. 2.Time dependent on hardware support. Some hardware provides multiple sets of registers per CPU -> multiple contexts loaded at once.

What are the advantages of having cooperating processes?

1.Information sharing 2.Computation speedup 3.Modularity 4.Convenience

What are the execution options of processes?

1.Parent and children execute concurrently. 2.Parent waits until children terminate.

What are the resource sharing options of processes?

1.Parent and children share all resources 2.Children share subset of parent's resources 3.Parent and child share no resources

Explain the creation of a process for Unix OS. (see pic 3.16)

A new process is created by the fork() system call. The new process consists of a copy of the address space of the original process. This mechanism allows the parent process to communicate easily with its child process. Both processes (the parent and the child) continue execution at the instruction after the fork(), with one difference: the return code for the fork() is zero for the new (child) process, whereas the (nonzero) process identifier of the child is returned to the parent. After a fork() system call, one of the two processes typically uses the exec() system call to replace the process's memory space with a new program. The exec() system call loads a binary file into memory and starts its execution. In this manner, the two processes are able to communicate and then go their separate ways. The parent can then create more children; or, if it has nothing else to do while the child runs, it can issue a wait() system call to move itself off the ready queue until the termination of the child. Because the call to exec() overlays the process's address space with a new program, the call to exec() does not return control unless an error occurs.

How is the sockets communication done?

A socket is defined as an endpoint for communication Concatenation of IP address and port - a number included at start of message packet to differentiate network services on a host The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 Communication consists between a pair of sockets All ports below 1024 are well known, used for standard services

How do you solve the problems of indirect communication in a mailbox sharing with three or more processes?

Allow a link to be associated with at most two processes Allow only one process at a time to execute a receive operation Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.

When is medium-term scheduling necessary? (see pic. 3.12)

Medium-term scheduling is necessary when the degree of multiple programming needs to decrease. It swaps by removing process from memory, store on disk and bring back from disk to continue execution.

What is message passing?

Message passing is the mechanism for processes to communicate and to synchronize their actons

How can message passing be?

Message passing may be either blocking or non-blocking.

Where differ the two models of IPC?(see pic 3.20)

In the shared-memory model, a region of memory that is shared by cooperating processes is established. Processes can then exchange information by reading and writing data to the shared region. In the message-passing model, communication takes place by means of messages exchanged between the cooperating processes.

Compare message passing and shared memory.

Message passing: Useful for exchanging smaller amounts of data Easier to implement Implemented using system calls Every message requires kernel intervention - slower Shared memory: Useful for exchanging larger amounts of data Requires synchronization System calls are only required to set up shared-memory region Once set up, all accesses are routine memory accesses, no further kernel assistance required - faster

How is a representation of process scheduling? (see pic. 3.10)

Is a queueing diagram where each rectangular box represents a queue. Two types of queues are present: the ready queue and a set of device queues. The circles represent the resources that serve the queues, and the arrows indicate the flow of processes in the system. A new process is initially put in the ready queue. It waits there until it is selected for execution, or dispatched. Once the process is allocated the CPU and is executing, one of several events could occur: • The process could issue an I/O request and then be placed in an I/O queue. • The process could create a new child process and wait for the child's termination. • The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue. In the first two cases, the process eventually switches from the waiting state to the ready state and is then put back in the ready queue. A process continues this cycle until it terminates, at which time it is removed from all queues and has its PCB and resources deallocated.

What does process scheduling do?

It maximize CPU use, and quickly switches processes onto CPU for time sharing.

What does a message system do?

It processes communication with each other without resorting to shared variables.

What are the properties of the communication link?

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 bidirectional

What are the type of communications in client server system?

Sockets Remote Procedure Calls

What happens when process execute the last statement?

Process executes last statement and asks the operating system to delete it (exit()): 1.Output data from child to parent (via wait()) 2.Process' resources are deallocated by operating system

What is a process?

Process is a program execution that must progress in a sequential fashion

What is an interprocess communication?

Processes within a system that may be independent or cooperating.

What does a program becomes process/es?

Program becomes process when executable file is loaded into memory.One program can be several process when multiple users execute the same program.

What is the difference between program and process?

Program is passive entity stored on disk while process is active.

What is buffering?

Queue of messages attached to the link.

How is a remote procedure call done? (see pic 3.39)

Remote procedure call (RPC) abstracts procedure calls between processes on networked systems Stubs - client-side proxy for the actual procedure on the server The client-side stub locates the server and marshalls the parameters The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server Data representation handled via External Data Representation (XDL) format to account for different architectures Remote communication has more failure scenarios than local Messages can be delivered exactly once rather than at most once OS typically provides a rendezvous (or matchmaker) service to connect client and server

What are schedulers and how many types of schedulers do we have?

Schedulers ensure that OS selects the correct process to execute. 1.Long term scheduler - select which process should be brought into the ready queue. It's invoked very infrequently and may be slow. 2.Short term scheduler - sometimes is the only scheduler in the system and selects which process should be executed next and allocates CPU.It's invoked very frequently and must be fast.

What is a device queue and how does the process work for it? (see pic 3.9)

Since there are many processes in the system, the disk may be busy with the request of some other process. The process therefore may have to wait for the disk. The list of processes waiting for a particular I/O device is called a device queue. Each device has its own device queue

How is a bounded buffer implemented?

The shared buffer is implemented as a circular array with two logical pointers: in and out. The variable in points to the next free position in the buffer; out points to the first full position in the buffer. The buffer is empty when in == out; the buffer is full when ((in + 1) % BUFFER SIZE) == out.

How is the CPU switch form process to process is done? (pic 3.7)

We know that CPU registers vary in number and type: accumulators, index-registers, stack-pointers, general purpose registers and any condition code information. Among with the program counter, the state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterwards.

What does a context switch do?

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.

Show the C code for the consumer process.

item next_consumed; while (true) { while (in == out) ; /* do nothing */ next_consumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; /* consume the item in next consumed */ }

Show the C code for the producer process.

item next_produced; while (true) { /* produce an item in next produced */ while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = next_produced; in = (in + 1) % BUFFER_SIZE; }


Related study sets

Chapter 24 Fluid, Electrolyte, and Acid-Base Balance

View Set

Blood Vessels and Circulation Anatomy II Exam 1

View Set

Unit 8 Transformations Ready for B2 First 4th Edition

View Set

Technical Support Fundamentals - Google Coursera Course - IT Support Professional Certification part 2

View Set