LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2008, 03:18 PM   #1
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Rep: Reputation: 15
Unhappy accessing the task_struct fields...


Hi,

I have a module which reads all the tasks in the system via task_struct structure and logs that information in /proc/process_info ( a dynamically created file in /proc by the module). It works fine if access the fields of
task struct like sleep_avg,prio, static_prio etc. But if I try to access the task->mm-> ANY FIELD , like mm->task_size mm->mm_count etc and try to view the /proc/process_info with vim , the vim comes out with segmentation fault.

I have no clue What is the issue here.. Thanks for any help...
 
Old 04-03-2008, 08:18 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
I presume that what you are doing cannot be handled by /proc/taskid/(whatever...)?

Or by any of the existing counters and metrics already available in the kernel?

Within the kernel, accessing any one of the task-structures is comparatively easy (so long as you properly lock it), and accessing a list of task-IDs is also comparatively easy. But in the general case, attempting to access every task in-detail would be a very expensive and failure-prone thing to do. Especially in a multiprocessor system: it would basically force the whole world to stop and wait for you.

You see, "the lock that owns the task-list" does not cover every task structure in that list: each one of these is individually locked. The task-list locks simply regulate insertion and deletion, i.e. the integrity of the list itself.

If you can by any means accomplish your objective, "close-enough," by means of the existing information published to user-space in /proc/taskid, you should definitely do so.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
task_struct access swaroopjoshi Linux - Kernel 1 11-15-2006 01:25 PM
task_struct of a process swaroopjoshi Linux - Kernel 1 11-09-2006 04:08 PM
differences in task_struct between 2.4 and 2.6 ploo Linux - Kernel 3 04-24-2006 04:09 AM
accessing task_struct of process shukla_chanchal Linux - General 1 11-04-2005 09:27 PM
Stuct task_struct dami Programming 1 10-13-2003 01:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration