comp.lang.ada
 help / color / mirror / Atom feed
* Re: Task management
  1999-06-17  0:00 Task management Dale Stanbrough
  1999-06-17  0:00 ` Decker, Christian R
@ 1999-06-17  0:00 ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: Larry Kilgallen @ 1999-06-17  0:00 UTC (permalink / raw)


In article <dale-1706991329100001@dale.cs.rmit.edu.au>, dale@cs.rmit.edu.au (Dale Stanbrough) writes:
> I'm sure the answer to my question is no, but anyway...
> 
>    Is there a way to determine how many processors a computer has
>    so that you can spawn the appropriate # of tasks to take advantage
>    of them (e.g. you may want to create sufficient tasks to farm work
>    out to, but not so many that you get thrashing).

Well certainly the answer is yes in some cases, depending on the
operating system.  But the question itself may not be the right
question to be asking, as you probably really care about how many
processors in the computer might be allocated to your Ada program
at a time, considering how your compiler implements tasking, how
the OS controls allocation of processors to user programs for that
tasking model (e.g., threads vs. separate processes) etc.

Larry Kilgallen




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Task management
  1999-06-17  0:00 Task management Dale Stanbrough
@ 1999-06-17  0:00 ` Decker, Christian R
  1999-06-17  0:00   ` Gerald Kasner
  1999-06-17  0:00 ` Larry Kilgallen
  1 sibling, 1 reply; 9+ messages in thread
From: Decker, Christian R @ 1999-06-17  0:00 UTC (permalink / raw)


If you are on an NT station ( I assume NT windows cuz win95 doesn't support
multi-cpu's ) then
the system call GetSystemInfo will return a C struct filled with all the
goodies.
the struct is defined as:  ( winbase.h , kernel32.lib )

typedef struct _SYSTEM_INFO { // sinf
    union {
        DWORD  dwOemId;
        struct {
            WORD wProcessorArchitecture;
            WORD wReserved;
        };
    };
    DWORD  dwPageSize;
    LPVOID lpMinimumApplicationAddress;
    LPVOID lpMaximumApplicationAddress;
    DWORD  dwActiveProcessorMask;
    DWORD  dwNumberOfProcessors;
    DWORD  dwProcessorType;
    DWORD  dwAllocationGranularity;
    WORD  wProcessorLevel;
    WORD  wProcessorRevision;
} SYSTEM_INFO




On a Unix Box I don't know the call, but i am sure it exists.



   -**** Posted from RemarQ, http://www.remarq.com/?a ****-
 Search and Read Usenet Discussions in your Browser - FREE -




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Task management
  1999-06-17  0:00 ` Decker, Christian R
@ 1999-06-17  0:00   ` Gerald Kasner
  0 siblings, 0 replies; 9+ messages in thread
From: Gerald Kasner @ 1999-06-17  0:00 UTC (permalink / raw)


Decker, Christian R wrote:
> 
> If you are on an NT station ( I assume NT windows cuz win95 doesn't support
> multi-cpu's ) then
> the system call GetSystemInfo will return a C struct filled with all the
> goodies.
> the struct is defined as:  ( winbase.h , kernel32.lib )
> 
> typedef struct _SYSTEM_INFO { // sinf
>     union {
>         DWORD  dwOemId;
>         struct {
>             WORD wProcessorArchitecture;
>             WORD wReserved;
>         };
>     };
>     DWORD  dwPageSize;
>     LPVOID lpMinimumApplicationAddress;
>     LPVOID lpMaximumApplicationAddress;
>     DWORD  dwActiveProcessorMask;
>     DWORD  dwNumberOfProcessors;
>     DWORD  dwProcessorType;
>     DWORD  dwAllocationGranularity;
>     WORD  wProcessorLevel;
>     WORD  wProcessorRevision;
> } SYSTEM_INFO
> 
> On a Unix Box I don't know the call, but i am sure it exists.
> 

Linux : in smp.h 
        extern int smp_num_cpus
        is defined

Gerald




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Task management
@ 1999-06-17  0:00 Dale Stanbrough
  1999-06-17  0:00 ` Decker, Christian R
  1999-06-17  0:00 ` Larry Kilgallen
  0 siblings, 2 replies; 9+ messages in thread
From: Dale Stanbrough @ 1999-06-17  0:00 UTC (permalink / raw)


I'm sure the answer to my question is no, but anyway...

   Is there a way to determine how many processors a computer has
   so that you can spawn the appropriate # of tasks to take advantage
   of them (e.g. you may want to create sufficient tasks to farm work
   out to, but not so many that you get thrashing).

If not how do people handle this situation?

Dale




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Task Management
@ 2005-12-28 11:27 The One Who Rages
  2005-12-28 12:28 ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: The One Who Rages @ 2005-12-28 11:27 UTC (permalink / raw)


Hello

I am new to ada.
I am trying to develop a simple system for managing
different(predefined) tasks.
I need to know time consumption for each task(f.e task with id 1 used
213 ms of processor). Could anyone point me vision of solution?
I can estimate of course, but it is not sattisfactying me.

I work under winXP, with gnat compiler.

Regards.

Christopher




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Task Management
  2005-12-28 11:27 Task Management The One Who Rages
@ 2005-12-28 12:28 ` Dmitry A. Kazakov
  2005-12-28 12:55   ` Martin Dowie
  2005-12-28 12:33 ` Stephen Leake
  2005-12-28 13:22 ` The One Who Rages
  2 siblings, 1 reply; 9+ messages in thread
From: Dmitry A. Kazakov @ 2005-12-28 12:28 UTC (permalink / raw)


On 28 Dec 2005 03:27:52 -0800, The One Who Rages wrote:

> I am new to ada.

You are welcome, though the following is not Ada question.

> I am trying to develop a simple system for managing
> different(predefined) tasks.
> I need to know time consumption for each task(f.e task with id 1 used
> 213 ms of processor). Could anyone point me vision of solution?
> I can estimate of course, but it is not sattisfactying me.
> 
> I work under winXP, with gnat compiler.

See Win32 API procedure GetThreadTimes in MSDN. GNAT Ada tasks are most
likely mapped to Windows threads. Call GetCurrentThread once from a task to
identify it. The result is a pseudo handle. Use DuplicateHandle on it to
get another (true) handle to the thread. This one can be used outside it
(in another task.)

P.S. GNAT has Win32 bindings.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Task Management
  2005-12-28 11:27 Task Management The One Who Rages
  2005-12-28 12:28 ` Dmitry A. Kazakov
@ 2005-12-28 12:33 ` Stephen Leake
  2005-12-28 13:22 ` The One Who Rages
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Leake @ 2005-12-28 12:33 UTC (permalink / raw)


"The One Who Rages" <Krzysztof.Daniel@gmail.com> writes:

> Hello
>
> I am new to ada.
> I am trying to develop a simple system for managing
> different(predefined) tasks.
> I need to know time consumption for each task(f.e task with id 1 used
> 213 ms of processor). Could anyone point me vision of solution?
> I can estimate of course, but it is not sattisfactying me.
>
> I work under winXP, with gnat compiler.

Using standard Ada, you can measure "wall clock time" for each task,
with Ada.Calendar. In each task, store the start and end time, by
calling Ada.Calendar.Clock.

But if the tasks interrupt each other, this is _not_ the per-task CPU
usage.

There is probably a Win32 API for this. Go to
http://msdn.microsoft.com/library, and search around. When you find
it, see if it is already imported in the GNAT Win32 bindings. Then see
if you can make it work :).

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Task Management
  2005-12-28 12:28 ` Dmitry A. Kazakov
@ 2005-12-28 12:55   ` Martin Dowie
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Dowie @ 2005-12-28 12:55 UTC (permalink / raw)


Dmitry A. Kazakov wrote:
> On 28 Dec 2005 03:27:52 -0800, The One Who Rages wrote:
> 
> 
>>I am new to ada.
> 
> 
> You are welcome, though the following is not Ada question.
> 
> 
>>I am trying to develop a simple system for managing
>>different(predefined) tasks.
>>I need to know time consumption for each task(f.e task with id 1 used
>>213 ms of processor). Could anyone point me vision of solution?
>>I can estimate of course, but it is not sattisfactying me.
>>
>>I work under winXP, with gnat compiler.
> 
> 
> See Win32 API procedure GetThreadTimes in MSDN. GNAT Ada tasks are most
> likely mapped to Windows threads. Call GetCurrentThread once from a task to
> identify it. The result is a pseudo handle. Use DuplicateHandle on it to
> get another (true) handle to the thread. This one can be used outside it
> (in another task.)
> 
> P.S. GNAT has Win32 bindings.

For Ada2005 there will be a new package "Ada.Execution_Time". I have a 
version of this that works with ObjectAda (i.e. Ada95) but not currently 
with GNAT. If anyone is interested in this, please email me. Perhaps 
I'll update my website someday! :-)

I'll see if I can update it to use a general solution using the above 
method described by Dmitry.

Cheers

-- Martin



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Task Management
  2005-12-28 11:27 Task Management The One Who Rages
  2005-12-28 12:28 ` Dmitry A. Kazakov
  2005-12-28 12:33 ` Stephen Leake
@ 2005-12-28 13:22 ` The One Who Rages
  2 siblings, 0 replies; 9+ messages in thread
From: The One Who Rages @ 2005-12-28 13:22 UTC (permalink / raw)


Thanks for your respones, I think I will try to use win32 bindings.
Thanks a lot once more.

Regards.
Chris




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-12-28 13:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-28 11:27 Task Management The One Who Rages
2005-12-28 12:28 ` Dmitry A. Kazakov
2005-12-28 12:55   ` Martin Dowie
2005-12-28 12:33 ` Stephen Leake
2005-12-28 13:22 ` The One Who Rages
  -- strict thread matches above, loose matches on Subject: below --
1999-06-17  0:00 Task management Dale Stanbrough
1999-06-17  0:00 ` Decker, Christian R
1999-06-17  0:00   ` Gerald Kasner
1999-06-17  0:00 ` Larry Kilgallen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox