LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 11-10-2006, 08:54 AM   #1
swaroopjoshi
LQ Newbie
 
Registered: Nov 2006
Location: Bangalore, India
Posts: 11

Rep: Reputation: 0
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
 
Old 11-10-2006, 04:02 PM   #2
sudhaanil
LQ Newbie
 
Registered: Nov 2006
Posts: 7

Rep: Reputation: 0
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.
 
Old 11-21-2006, 12:23 AM   #3
someshwar
LQ Newbie
 
Registered: Oct 2006
Posts: 14

Rep: Reputation: 0
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

Last edited by someshwar; 11-24-2006 at 12:38 AM.
 
Old 11-21-2006, 11:27 AM   #4
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,048

Rep: Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953Reputation: 953
Umm... the kernel already has load-balancing features. Have you read the Documentation section of the kernel source-tree?
 
Old 11-22-2006, 08:08 AM   #5
swaroopjoshi
LQ Newbie
 
Registered: Nov 2006
Location: Bangalore, India
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 11-24-2006, 12:41 AM   #6
someshwar
LQ Newbie
 
Registered: Oct 2006
Posts: 14

Rep: Reputation: 0
Gr8...

I think ur using current pointer to traverse task list.

How u r passing pid to ur module?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Context switch arunachalam Linux - General 3 06-15-2009 01:21 PM
How can a process know if it has access to a given io address range? hughug Programming 0 05-22-2006 06:20 PM
process and memory access phoenix7 Linux - Software 4 08-30-2005 10:25 AM
context of a library perfect_circle Programming 2 03-17-2005 12:14 PM
number of process or users that can access the same file infusino Linux - Newbie 6 11-28-2002 10:50 AM


All times are GMT -5. The time now is 12:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration