I need a little more explanation with Creation of Process in OS - process

I was going through the Process States. The first state was "Creating Process". What do we mean by creating the process? Is it the completion the program and saving into the hard disk?

The state 'Creating Process' is what you refer to before it goes into a ready state, that is ready to be scheduled by the OS. The process creation state refers to the initial setup of the essentials of a process. In UNIX, at system boot, the first user level process is created called 'init' which is the parent of all the other processes.
UNIX fork() is used to create a new process. During this process creation, the fork() will create a new address space for the child process, a process id (pid) will be assigned, all the mapping of the parent process will be copied into the child's address space and the new program will be loaded in to the child process's address space. This is what happens in 'Process Creation' and once fork() it is followed by a exec() call which will allow the child to run its own program.

Related

TASK_RUNNING process state

I am reading "Linux Kernel Development". It has definition about "TASK_RUNNING"
"TASK_RUNNING—The process is runnable; it is either currently running or on a runqueue waiting to run". My question is why don't we have two separate state for "currently running" and "on a runqueue waiting to run". Like TASK__RUNNING and TASK_READYTORUN.
1) because when I first look at word "TASK_RUNNING", I thought it just refers to a running process state
2) more exact definition would avoid many troubles
So do we have strong reasons not to do this ??
The process is runnable.
Futher state separation has no sence from the view of users of this field.
Because users of that state are not interact with a scheduler, knowing whether a process is scheduled or not is useless: immediately after you obtain that knowledge, the scheduler may change that property, so your knowledge becomes invalid.
As for name TASK_RUNNING, only Linux developers knows why it is choosen. It could be historic reason, or intentionally: "Think of the process as if it is running."

Add a watch while creating a lock using Curator Lock API

We have a specific case where one process will acquire a Curator lock on a key and will attach a Watch. The other process also attaches a Watch on the same key. I want the other process to be notified whenever the Lock is released: either by the process itself, or by ZooKeeper when the process is dead.
I am trying with NodeCache, but I guess NodeCache does not work when znode type is EPHEMERAL_SEQUENTIAL. At least, my test case fails.
I managed to solve the problem using PathChildrenCache instead of NodeCache.The curator locking API creates an EPHEMERAL_SEQUENCE mode on zk. So it was difficult to provide the exact path to NodeCache to watch upon.
The PathChiredrenCache implementation will be called back when any of the process uses the lock on the same key as they will create child nodes inside that key on zookeeper.

Process state transition from READY to TERMINATED

This is a theoretical operating systems question:
In which occasions can a process go from the READY state directly to the TERMINATED state without passing through RUNNING?
Is this just happening when the process is killed while being in READY state?
Let there is a parent process which have 3 child process. If parent process is processing and after some time, it abort then the child process will gone from ready to terminated state.

process states - new state & ready state

As OS concepts book illustrate this section "Process States":
Process has defined states: new, ready, running, waiting and terminated.
I have conflict between new and ready states, I know that in ready state the process is allocated in memory and all resources needed at creation time is allocated but it is only waiting for CPU time (scheduling).
But what is the new state? what is the previous stage before allocating it in memory?
All the tasks that the OS has to perform cannot be allocated memory immediately after the task is submitted to the OS. So they have to remain in the new state. The decision as to when they move to the ready state is taken by the Long term scheduler. More info about long term scheduler here http://en.wikipedia.org/wiki/Scheduling_(computing)#Long-term_scheduling
To be more precise,the new state is for those processes which are just being created.These haven't been created fully and are in it's growing stage.
Whereas,the ready state means that the process created which is stored in PCB(Process Control Block) has got all the resources which it required for execution,but CPU is not running that process' instructions,
I am giving you a simple example :-
Say, you are having 2 processes.Process A is syncing your data over cloud storage and Process B is printing other data.
So,in case process B is getting created to be stored in PCB,the other
process,Process A has been already created and is not getting the
chance to run because CPU hasn't called these instructions of Process
A.But,Process B requires printer to be found and other drivers to be
checked.It must also check for verification of pages to be printed!
So,here Process A has been created and is waiting for
CPU-time---hence,in ready state. Whereas,Process B is waiting for
printer to be initialised and files to be examined to be
printed--->Hence,in new state(That means these processes haven't been
successfully added into PCB).
One more thing to guide you isFor each process there is a Process Control Block, PCB, which stores the process-specific information.
I hope it clears your doubt.Feel free to comment whatever you don't understand...

Application calls another Application. Does it create another process?

I was reading about Processes. I wan't to know what really happens. My situation :
"I opened an Application. That creates a process say process1. I have other applications interfaced with this one and all these open up when i click a button inside my running application. I want to know Does my process1 create new processes and IPC happens OR processes for all the linked applications are created at once and then IPC happens?"
Obviously,a running application is a bunch of processes,or maybe a single process which has internally multiple threads acting within these processes.
So,your activity decides the creation and deletion of processes.say,if you are running an application such as media player and you suddenly start searching related info about the album---so here,totally a new process is created which helps interaction through web and after returning the output,it may die,may not,but the process was created on your request.Also,mostly ipc happens within processes,exactly as per your thinking,but shared memory communication is also one of the option,which is complicated and is less common.
One more thing to point out is that there are several 'daemon processes' which are running in the background and don't die before shutdown instruction!So,these processes are also sometimes related to the running application and serves its request.But,mostly,newer processes are created when we switch our task or perform certain action in the application.