--- tags: 作業系統 --- # 作業系統 Ch3 Processes ### Process part - text - data section: global variable - stack: temporary data - heap ### PCB ( process control block ) - process state - program counter - CPU register - CPU scheduling information - momery management information - accounting information - I/O status information ### Scheduler - long-term: determination degree of multiprogramming - short-term - I/O bound process - CPU bound process ### multitask in mobile systems - Android: background service use a service to platform tasks ### context switch - time dependent on hardware support: sets of register per CPU -> multiple context load at once ### process termination - cascading termination: if parent exit, child terminate - zombie: if no parent waiting - orphan: if parent terminate without invoking wait ### multiprocess architecture - Chrome - browser - renderer - plug-in ### Interprocess communication - cooperating advantage: > information sharing > computation speedup > modularity > convenience - modal of IPC (interprocess communication) > shared memory > message passing - Producer-Consumer problem > unbounded-buffer: no limit buffer size > bounded-buffer: fixed buffer size - shared memory > communication under user mode not os > Major problem: synchronize > POSIX - message passing > send、receive > communication link > example of IPC systems - Mach: msg based > example of IPC systems - Windows: msg passing via LPC(local procedure call)、connection port、on the same system >synchronize >>blocking、Non-blocking >>rendezvous: both send and receive is blocking >buffering >>zero capacity: no msg are queued on the link, sender must wait for receiver >>bounded capacity >>unbounded capacity ### Client-Server communication - sockets: >endpoint >port 小於1024 well known >3 socket type in Java: TCP、UDP、MulticastSocket) - pipes >ordinary pipes: undirectional >names pipes: bidirectional、can access without parent-children relationship - remote precedure calls >stubs: client-side proxy for the actual procedure on server (Microsoft Interface Definition Language) >marshall the parameter(從 memory 輸入到 hard disk 後傳送) >msg pass exactly once >external data representation (XDL) for different architecture - remote method invocation (Java) ### command - fork() - exec(): replace the process memory space with program - abort(): parent terminate execution of children process - exit() - grep(): search file content