Hello readers!!! Welcome to the first sub-section of interprocess communication. Interprocess communication is a very useful topic, not only from point of view of android but from other aspects of computer science. Many of you would have background from computer science they will be definitely aware of this fundamental concept. Those who don’t have computer science background, don’t worry we shall go through a small introduction to interprocess communication. Let us start diving deep into this section.
A process can be rightly thought as a program in execution. Generally to accomplish a task, a process needs resources. For instance, CPU file, memory, etc. Resources are allocated to processes in two stages i.e., the stage when process was created or dynamically allocate the process while they are running.
Figure Program in execution is known as process
A process is more than a coding or program of code; it includes current activity, content of processor’s registers, etc. Program can be thought of as an passive entity, process is an active entity. It contains a feature which is known as program counter. Program counter is responsible for specifying the next instruction to be executed. Word processor can be thought of as a process. So when we talk about a passive entity it would be lika a file containing set of instructions saved on a disk which is also known as executable file, whereas process ia meant to be an active entity which is backed by a program counter which in turn specifies the next instruction to be executed along with a set of associated resources. In other words program converts into a process when it is loaded into memory. Following diagram would depict the same statement pictorially which is as shown below:
Figure Program and process
12.1.2 Structure of process in memory
Following diagram shows the structure of process in memory
Figure Process in memory
Let us have a quick glance on these constituents of the process in memory and they are:
- Stack: It contains temporary data such as parameters of function, return addresses, and local variables.
- Heap: It is a memory that is dynamically allocated during process run time.
- Data: It includes global variables
- Text: It includes the current activity which is represented by the value of program counter and the contents of the processor's registers.
12.1.3 States of process and Process Control Block (PCB)
We are going to cover two sub-topics under this topic and they are:
184.108.40.206 Process State
Just like liquid changes its state process too changes its states during execution. Major transition states of process are namely:
- New: Process is created
- Running: Instructions are executed
- Ready: Process is ready to get executed and is waiting to get assigned to processor
- Waiting: Any event of line need to be performed hence process is waiting for that event to occur
- Terminated: Execution or process is accomplished
The states that they represent are found on all systems but certain operating systems also more finely delineate states of process. The names may vary according to different operating systems. There can be more than one process which are in ready or waiting state but at any instant of time one and only one process can be in running state at one processor. Pictorial representation of process states is as follows:
Figure Process states
220.127.116.11 PROCESS CONTROL BLOCK (PCB)
You must be thinking there are so many processes and how are they going to be represented in operating system well, we have process control block which uniquely represents each process in operating system. It is also called task control block. PCB contains associated information which is as follows:
- Process state: A process can be in new, ready, running, etc.
- Program counter: It contains address of next instruction to be executed.
- Registers: CPU registers include accumulators, index registers, stack pointers, and general-purpose registers. It also includes condition-code information. The number of registers and their type may be different in different architecture.
- Memory management: It also includes information about memory management. Depending on the memory system used by the operating system it may include information such as the value of the base and limit registers, the page tables, or the segment tables.
- CPU-Scheduling system: It includes information such as priority of process, scheduling parameters, pointers to scheduling queues, etc.
- Accounting information: This overtures the information like time limits, amount o CPU and real time used, job or process numbers, account numbers, etc.
- I/O status information: It includes information like list of IO devices, list of open files, etc.
Figure Process Control Block (PCB)
12.1.4 Android and interprocess communication
Android can host variety of applications and it is designed in a way which removes redundancy or duplication of functionalities in different applications or to allow functionality to be discovered, etc.
There are two major techniques related to interprocess communication and they are namely;
- Intents: These enable an application to select an Activity based on the action you want to invoke and the data on which they operate. Hardcoded path to an application is needed to use its functions and exchange data with it. With intent objects data can be used t pass objects in both directions. It enables a high-level interprocess communication.
- Remote methods: By this we mean the remote procedure calls (RPCs) with this APIs can be accessed remotely. With remote calls, the methods appear to be local which are executed in another process. Android Interface Definition Language (AIDL) is used for this purpose.
Android applications avoid interprocess communication. It provides functions in packages loaded by applications that require them. For applications to exchange data applications need to use file system or other traditional Unix/Linux IPC mechanisms,
Congratulations ladies and gentlemenJ!!! We are done with this section. See you in the next section. Till then keep practicing. Happy App Developing!!!