Programming Implementation Grammar's

profilelarryh65
token.txt

1-Information sharing  2-Computation speedup 3-Modularity 4-Convenience 5-allows exchanged data and informations Two IPC Models 1. Shared memory- is an OS provided abstraction which allows a memory region to be simultaneously accessed by multiple programs with an intent to provide communication among them. One process will create an area in RAM which other processes can accessed 2. Message passing - is a form of communication used in interprocess communication. Communication is made by the sending of messages to recipients. Each process should be able to name the other processes. The producer typically uses send() system call to send messages, and the consumer uses receive()system call to receive messages Shared memory Faster than message passing After establishing shared memory, treated as routine memory accesses Message passing Useful for exchanging smaller amounts of data Easy to implement, but more time-consuming task of kernel intervention Bounded-Buffer Problem Producer Process do { ... produce an item in nextp ... wait(empty); wait(mutex); ... add nextp to buffer ... signal(mutex); signal(full); } while (true); Bounded-Buffer Problem Consumer Process do { wait(full); wait(mutex); ... remove an item from buffer to nextc ... signal(mutex); signal(empty); ... consume the item in nextc ... } while (true); client-server model, the client sends out requests to the server, and the server does some processing with the request(s) received, and returns a reply (or replies)to the client. Since Socket can be described as end-points for communication. we could imagine the client and server hosts being connected by a pipe through which data-flow takes place. 1-sockets use a client-server while Server waits for incoming client requests by listening to a specified port. 2-After receiving a request, the server accepts a connection from the client socket to complete the connection 3-then Remote procedure call (RPC) abstracts procedure call mechanism for use between systems with network connections 4-and pipes acts as a conduit allowing two processes to communicate A process is different than a program - Program is static code and static data - Process is Dynamic instance of code and data -Program becomes process when executable file loaded into memory No one-to-one mapping between programs and processes -can have multiple processes of the same program -one program can invoke multiple process Execution of program started via GUI mouse clicks and command line entry of its name The process state transition As a process executes, The process is being created, then The process is waiting to be assigned to a processor therefore, Instructions are being executed then The process is waiting for some event to occur,thereafter The process has finished execution Parent process creates children processes, which, in turn create other processes, forming a tree of processes The new child process is a complete copy of the executing program Generally, process identified and managed via a process identifier (pid) getpid () The new child process has a new process identifier. fork () returns the child’s PID to the parent, 0 to the child. When calling exec (), all data in the original program is lost, and replaced with a running copy of the new program: Overlaying UNIX examples fork () system call creates new process exec () system call used after a fork() to replace the process’ memory space with a new program