Operating System - HP-UX
1847663 Members
3345 Online
110265 Solutions
New Discussion

Re: How a Process span across CPU

 
joinsiva
Advisor

How a Process span across CPU

Hi gurus,

i hve a quiery !.

i hve a rp server, with 4 cpus.

My quiery is, a user process is running on cpu 0, now if that process grows to occupy more cpu, How the allocation happens ?

option 1: whether it grows up to 100% in cpu0 and spans to the next one ? (is the application support is needed for that or it is a OS duty to do it ? )

option 2: whether parallel allocation is made to the other cpus ? instead of making one cpu 100% ?

Thanks in advance

Sivakumar P
3 REPLIES 3
Ninad_1
Honored Contributor

Re: How a Process span across CPU

Sivakumar,

A single process will be running on a single processor, unless you have the application capable of multi threading - which will spawn multiple processes in parallel to exceute. But this totally depends on your application.
The process can use anywhere between 0-100 % of a processor time indicated by the pcpu field if you run the ps -ef command. The same process can get allocated to another processor during the execution-life of the process as usually the OS will need to time-share other processes running on your system so that they also get timeslice of the processor to execute. Thus you may find a particular process currently running on say CPU0 and after some time on say CPU1 etc.
All this - allocating processor resources to the processes is done by the kernel based on the priority of the process, state of the process and other processes running on your system at that time.

Hope this clarifies.
Ninad
Steven E. Protter
Exalted Contributor

Re: How a Process span across CPU

Shalom sivakumar,

A single process doing a single job is not going to be able to use two cpus at the same time.

Since Unix provides process time on a time slice basis, it may move from cpu to cpu at time. It is possible to bind a process to a cpu, which will make system operation less efficient for every other process, but is done in certain circumstances.

Now if a program or even a script is written in such a way that there are multiple threads or processes, then its possible the program or script will run on multiple cpus.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
joinsiva
Advisor

Re: How a Process span across CPU

Hi all,

Thanks for your answers. It cleared my doubt.

Sivakumar P