LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
LinkBack Search this Thread
Old 03-05-2006, 11:48 PM   #1
sharathksin
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Rep: Reputation: 0
Calculating the percentage completion of a process


I want to calculate the percentage completion of process and time remaining using a C program.I know the PID of the process to be monitored & that process will be running along with the C program.Can anybody help me with sample program.
Thanks in advance
 
Old 03-06-2006, 12:28 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,740

Rep: Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905
Unless the process you are monitoring is telling you how it's doing eg logs each step it does, you can't calc how far it's got ...
Note that even that won't work (timewise) if the work to be done is variable, or the sys load varies significantly.
 
Old 03-06-2006, 01:44 AM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 33
I guess it won't be easy without modifying the program.
You can always use getrusage() to get the time spent so far and have the program in question print deltas when you send it signals (ie, SIGUSR1). The remaining time is always relative to the task at question and system load, too. Fortunately, getrusage() is precise enough because it says the effective time spent running.
 
  


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
bash cut command to get df percentage nutthick Programming 8 12-16-2010 11:02 AM
ps -aux CPU usage percentage depdiver Linux - General 1 02-25-2006 02:02 AM
find remaining percentage of cpu happy78 Programming 11 09-26-2005 08:02 PM
Percentage of zero post users ? samael26 LQ Suggestions & Feedback 5 05-29-2005 04:18 PM
What is the percentage of each distro in use ? newlin Linux - General 1 08-03-2003 04:41 PM


All times are GMT -5. The time now is 03:14 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
Open Source Consulting | Domain Registration