LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-21-2013, 05:27 PM   #1
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 166
Blog Entries: 1

Rep: Reputation: 4
How is the time utility affected by multithreading?


If I run the time command around a multi-threaded application, how is it affected? In this case, what do the user and sys times represent? Is it the sum of all times used by the various threads, or...?
 
Old 08-21-2013, 05:49 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
The times reported for a process will be the time consumed by that process alone ... but this will be somewhat-less than elapsed time, and this is where/how the effect of multitasking can be seen.

When the dispatcher hands control to a process/thread, and then takes it away again a few microseconds later, it keeps an accounting of how much time the process consumed. When the process makes system-calls and subsequently returns from those calls, the elapsed-time spent servicing a system-call is also accounted for.

All of these times are intended to be used only for comparative purposes. They are not exact, and they can vary due to a myriad of possible factors.
 
Old 08-21-2013, 06:17 PM   #3
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 166

Original Poster
Blog Entries: 1

Rep: Reputation: 4
I'm not quite clear on this -- because I used time a program using implicit parallelization (a schemik script) and I get times like so:

real 0m0.776s
user 0m1.310s
sys 0m0.020s

This is why I am wondering if "user" is the sum of the times, since presumably otherwise user cannot be greater than actual elapsed time, right?
 
Old 08-21-2013, 07:04 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
"This is why I am wondering if "user" is the sum of the times, since presumably otherwise user cannot be greater than actual elapsed time, right?"

An application's time can be greater than real time if the application is multi-threaded and you time the application on a multi-CPU machine. However an application's time cannot be greater than real time multiplied by the number of CPUs.

I have done such multi-CPU timings on IBM mainframes where the application time exceeded real time but I have never tried to do it on an x86.

------------------------
Steve Stites

Last edited by jailbait; 08-21-2013 at 07:37 PM.
 
  


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
[SOLVED] (Fedora) Utility to minimize inactive windows after a period of time dereism Linux - Software 3 02-11-2013 12:00 PM
client server with UDP/TCP utility at same time in same programe shahidali_52 Linux - Newbie 2 05-17-2012 12:33 PM
System time getting affected...? deostroll Ubuntu 3 01-10-2008 06:13 PM
utility to update the last modified time of a directory RajRed Linux - Newbie 4 02-20-2006 04:34 PM
Time synchronizing utility jkcunningham Linux - Software 5 11-13-2004 02:17 AM

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

All times are GMT -5. The time now is 05:48 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