OS 3 Processes
What is the hierarchy of processes in android from most to least important?
1 Foreground process 2 Visible process 3 Service process 4 Background process 5 Empty process
What are the different states of a process?
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 processScreen Shot 2019-09-23 at 3.16.38 pm is waiting to be assigned to a processor 5 Terminated: The process has finished execution
What is interprocess communication (IPC) for cooperating processes and the two types?
1 Shared memory 2 Message passing
What are the three types of sockets?
1 TCP: connection-orineted 2 UDP: connectionless 3 MulticastSocket: data can be sent to multiple recipients
What are the 5 key aspects of a process?
1 The program code, also called text section 2 Current activity including program counter, processor registers 3 Stack containing temporary dataFunction parameters, return addresses, local variables 4 Data section containing global variables 5 Heap containing memory dynamically allocated during run time
What are the steps to create indirect communication link between processes?
1 create a new mailbox (port) 2 send and receive messages through mailbox 3 destroy a mailbox Primitives are defined as: → send(A, message) - send a message to mailbox A → receive(A, message) - receive a message from mailbox A
What is a context switch?
A context switch occurs when the CPU switches from one process to another.
What are processes in operating systems?
An operating system executes a variety of programs that run as a process. Process: a program in execScreen Shot 2019-09-23 at 3.14.47 pmution; process execution must progress in sequential fashion
What is cascading process termination?
Cascading Process Termination: some OS do not allow child to exists if its parent has terminated. If a process terminates, then all its children must also be terminated.
What is the difference between independent and cooperating processes?
Cooperating Process: can affect or be affected by other processes, including sharing data → cooperating processes need interprocess communication (IPC) → type models of IPC: shared memory & message passsing Independent Process: cannot affect or be affected by the execution of another process
What is the different between direct and indirect communication links?
Direct → processes must name each other explicitly → links are automatic → each link is associated with one pair of processes → links can be unidirectional but often bi-directional Indirect → messages are sent and received from mailboxes (ports) → each mailbox has unique ID → processes can only communicate/establish a link if they share a mailbox → a link can have many processes and vice versa → links can be uni or bi-directional
How does multi-tasking vary between Android and IOS?
Due to screen real estate, user interface limits iOS provides for a → Single foreground process- controlled via user interface → Multiple background processes- in memory, running, but not on the display, and with limits → Limits include single, short task, receiving notification of events, specific long-running tasks like audio playback Android runs foreground and background, with fewer limits → Background process uses a service to perform tasks → Service can keep running even if background process is suspended → Service has no user interface, small memory use
What are communication links in interprocess message passing?
If processes P and Q wish to communicate, they need to: → Establish a communication link between them → Exchange messages via send/receive Physical Implementation of Link → shared memory → hardware bus → network Logical Implementation → direct vs indirect → synchronous vs asynchronous → automatic or explicit buffering
What is the Process Control Block (PCB)?
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 infoScreen Shot 2019-09-23 at 3.21.01 pmrmation: CPU used, clock time elapsed since start, time limits I/O status information: I/O devices allocated to process, list of open files
How does a Mach inter-process communication (IPC) system function?
Mach communication is message based → Even system calls are messages → Each task gets two ports at creation- Kernel and Notify → Messages are sent and received using the mach_msg() function → Ports needed for communication, created via mach_port_allocate() → Send and receive are flexible, for example four options if mailbox full: ---- Wait indefinScreen Shot 2019-10-14 at 2.16.12 pmitely ---- Wait at most n milliseconds ---- Return immediately ---- Temporarily cache a message
What is a process scheduler?
Maximize CPU use, quickly switch processes onto CPU core Process scheduler selects among available processes for next execution on CPU core Maintains scheduling queues of processes → Ready queue - set of all processes residing in main memory, ready and waiting to execute → Wait queues - set of processes waiting for an event (i.e. I/O) → Processes migrate among the various queues
How does a Windows inter-process communication (IPC) system function?
Message-passing centric via advanced local procedure call (LPC) facility → Only works between processes on the same system → Uses ports (like mailboxes) to establish and maintain communication channels Communication works as follows: → client opens a handle to the subsystem's connection port object. → client sends a connection request → server creates two private communication ports and returns the handle to one of them to thScreen Shot 2019-10-14 at 2.18.34 pme client. → client and server use the corresponding port handle to send messages or callbacks and to listen for replies
What are named communication pipes and how do they function?
Named pipes: can be accessed without a parent-child relationship. → more powerful than ordinary pipes → communication is bidirectional → No parent-child relationship is necessary → Several processes can use the named pipe for communication → Provided on both UNIX and Windows systems
What are ordinary communication pipes and how do they function?
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 that it created. → Producer writes to one end (the write-end of the pipe) → Consumer reads from the other end (the read-end of the pipe) → unidirectional → require parent-Screen Shot 2019-10-14 at 2.21.28 pmchild relationship → Windows calls these anonymous pipes
How does a POSIX inter-process communication (IPC) system function?
POSIX Shared Memory → Process first creates shared memory segment ---- shm_fd = shm_open(name, O CREAT | O RDWR, 0666); → Also used to open an existing segment → Set the size of the object ----- ftruncate(shm_fd, 4096); → Use mmap() to memory-map a file pointer to the shared memory object → Reading and writing to shared memory is done by using the pointer returned by mmap().
What are producers and consumers in processes and buffers?
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
How is a process created?
Parent process create children processes, which, in turn create other processes, forming a tree of processes → process identiScreen Shot 2019-10-14 at 1.09.16 pmfied and managed via a process identifier (pid)
What are pipes for inter-process communication (IPC) and the two types?
Pipes: acts as a conduit allowing two processes to communicate Two types: → 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 that it created. → Named pipes: can be accessed without a parent-child relationship.
How is a process terminated?
Process executes last statement then asks the operating system to delete it using the exit() system call. → returns status data from child to parent via wait() → resources are deallocated by operating system Parent may terminate the execution of children processes using the abort() system call
What is a process concept?
Program is a passive entity stored on disk (executable file); the process is active → program becomes process when executable file loaded into memory → execution of program started via GUI mouse clicks, command line entry of its name, etc. → one program can be several processes → consider multiple users executing the same program .
What are the types of queues maintained by a process scheduler?
Ready queue - set of all processes residing in main memory, ready and waiting to execute Wait queues - set of processes waiting for an event (i.e. I/O) → Processes migrate among the various queues
What are reasons and advantages of cooperating processes?
Reasons and Advantages → Information sharing → Computation speedup → Modularity → Convenience
What are remote procedure calls?
Remote procedure call (RPC): abstracts procedure calls between processes on networked systems → uses ports for service differentiation → Stubs: client-side proxy for the actual procedure on the server → client-side stub locates the server and marshalls the parameters → server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server → On Windows, stub code compile from specification written in Microsoft Interface Definition Language (MIDL)
What are the different ways a process can share resources and execute?
Resource Sharing → parent and child share all resources → children share subset of parent's resources → parent and child do not share Execution → parent and children execute concurrently → parent waits until child terminates
What is a single process and multiprocess browser?
Single Process Browser: if one web site causes trouble, entire browser can hang or crash Multiprocess Browser: can have multiple different types of processes → e.g. Chrome with browser, renderer, and plugin → browser process manages user interface, disk and network I/O → renderer process renders web pages, deals with HTML, Javascript. A new renderer created for each website opened → plug-in process for each type of plug-in
What are Threads?
So far, process has a single thread of execution → Consider having multiple program counters per process ---- Multiple locations can execute at once ---- Multiple threads of control -> threads → Must then have storage for thread details, multipleprogram counters in PCB
What are sockets?
Socket: A socket is defined as an endpoint for communication → includes IP address and port - a number included at start of message packet to differentiate network services on a host ---- e.g. the socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 → Communication between a pair of sockets → ports below 1024 are well known, used for standard services → Special IP address 127.0.0.1 (loopback) to refer to system on which process is running
How does multitasking in mobile systems operate
Some mobile systems (e.g., early version of iOS) allow only one process to run, others suspended Due to screen real estate, user interface limits iOS provides for a → Single foreground process - controlled via user interface → Multiple background processes- in memory, running, but not on the display, and with limits → Limits include single, short task, receiving notification of events, specific long-running tasks like audio playback Android runs foreground and background, with fewer limits → Background process uses a service to perform tasks → Service can keep running even if background process is suspended → Service has no user interface, small memory use
What is the difference between blocking/synchronous and non-blocking/asynchronous message passing ?
Synchronous Blocking → blocking send: the sender is blocked until the message is received → blocking receive: the receiver is blocked until a message is available Asynchronous Non-Blocking → non-blocking send: the sender sends the message and continue → non-blocking receive: the receiver receives a valid message or null message Rendezvous: if both send and receive are blocking
How does a CPU switch from one process to another?
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. → Context of a process represented in the 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 ---- Some hardware provides multiple sets of registers per CPU → multiple contexts loaded at once
What are the three ways a buffering queue of messages can be attached to a communication link?
Zero capacity: no messages are queued on a link, sender must wait for receiver (rendezvous) Bounded capacity: finite length of n messages, sender must wait if link full Unbounded capacity: infinite length, sender never waits
What is a zombie and orphan process?
Zombie: a child with no parent waiting (did not invoke wait()) Orphan: if a parent terminated without invoking wait
How does an advanced local procedure call (LPC) facility function for a inter-process communication (IPC) system function?
advanced local procedure call (LPC) facility → Only works between processes on the same system → Uses ports (like mailboxes) to establish and maintain communication channels Communication works as follows: → client opens a handle to the subsystem's connection port object. → client sends a connection request → server creates two private communication ports and returns the handle to one of them to the client. → client and server use the corresponding port handle to send messages or callbacks and to listen for replies
Why might a process be terminated using the abort() system call?
→ Child has exceeded allocated resources → Task assigned to child is no longer required → The parent is exiting and the operating systems does not allow a child to continue if its parent terminates
What is the shared memory in interprocess communication and major issues with this function?
→ area of memory shared among the processes that wish to communicate → communication is under the control of the users processes not the operating system. → major issues is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory.
What is the message passing in interprocess communication and major issues with this function?
→ mechanism for processes to communicate and to synchronize their actions → message system - processes communicate with each other without resorting to shared variables → IPC facility provides two operations: ---- send(message) ---- receive(message) → The message size is either fixed or variable