LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   access to context of a process (https://www.linuxquestions.org/questions/linux-kernel-70/access-to-context-of-a-process-500329/)

swaroopjoshi 11-10-2006 08:54 AM

access to context of a process
 
Hi folks,
I am working on prcocess migration in linux using C language.
I wish to access the context of a process-the contents stored in its process control block like-program counter, address space, list of open files, pending signals, accounting information, etc.
After this, i need to freeze the process and execute it on another machine.
Basically i am trying to acheive load balacing.
Can you tell me how to access the context of a process wen i have its pid(using getpid())?
Is it possible through task_struct? Or is there any other way? Please give me as much details as possible.
My mail id is: swaroopbjoshi@yahoo.co.in

sudhaanil 11-10-2006 04:02 PM

Hi,

From what I understand, "setJmp" and "longJmp" functions might do the trick. Look at their man pages.

In the worst case, you may have to do inline assembly to save the context incluing PC and other registers. May be there is a smarter way, I donno ?

Thanks,
Anil.

someshwar 11-21-2006 12:23 AM

To do tht we need pointer to task_stuct.
Without tht pointer we can't access task related information.

We can access "task_struct" of current task using "current" pointer provided by the Kernel.

through pid how can we get pointer to task_struct ?
I think,this not the correct approach to get process information.

I hope, I am clear to u

sundialsvcs 11-21-2006 11:27 AM

Umm... the kernel already has load-balancing features. Have you read the Documentation section of the kernel source-tree?

swaroopjoshi 11-22-2006 08:08 AM

Quote:

Originally Posted by someshwar
To do tht we need pointer to task_stuct.
Without tht pointer we can't access task related information.

We can access "task_struct" of current task using "current" pointer provided by the Kernel.

through pid how can we get pointer to task_struct ?
I think we this not the correct approach to get process information.

I hope, I am clear to u

Hi someshwar,
Thanks for reply.
I found out how to access pcb of process in 2.4 kernel.
It can be done by using init_module()...By matching pid of a process wit others in the task_struct list maintained by kernel, its possible to access task_struct contents of required process.
Swaroop.

someshwar 11-24-2006 12:41 AM

Gr8...

I think ur using current pointer to traverse task list.

How u r passing pid to ur module?


All times are GMT -5. The time now is 04:16 AM.