comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: A Simpler Find Tool
Date: Sun, 21 May 2017 07:49:31 +0100
Date: 2017-05-21T07:49:31+01:00	[thread overview]
Message-ID: <lyfufyso04.fsf@pushface.org> (raw)
In-Reply-To: d39a1cbe-9068-4cc3-8f0e-c05e4700befc@googlegroups.com

Brian Kolden <bakolden5@gmail.com> writes:

> I made a simple find tool for Linux, https://github.com/bkold/finda,
> and I was wondering if I could optimize the task scheduling a bit.
>
> 	protected body Task_Pool_Status is
> 		procedure Check (Thread_Pointer : out Thread_Access) is
> 		begin
> 			for I in Status'Range loop
> 				if Status(I) = Ready then
> 					Status(I) := Working;
> 					Thread_Pointer := Threads(I);
> 					return;
> 				end if;
> 			end loop;
> 			Thread_Pointer := Null;
> 		end Check;
>
> 		procedure End_Thread (Thread_Num : in CPU) is
> 		begin
> 			Status(Thread_Num) := Ready;
> 		end End_Thread;
> 	end Task_Pool_Status;
>
> I'm using a request and reserve model to determine which threads are
> waiting and which are busy. The threads call End_Thread when they
> finish their work in order to be available to be queued again. I think
> the model itself is good, but I was unhappy with how I find the
> sleeping threads. Does anyone have a cleaner suggestion?

Just how many threads are you expecting to have? Is it worth saving some
cycles here?

You could have a queue of Ready threads, pop a thread when required,
push when done. That would allow you to have an entry, which would save
the polling?

   entry Get (A_Thread : out Thread_Access) when Queue.Head /= null
   is

  reply	other threads:[~2017-05-21  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-21  5:04 A Simpler Find Tool Brian Kolden
2017-05-21  6:49 ` Simon Wright [this message]
2017-05-22  3:19   ` Brian Kolden
2017-05-21  9:44 ` G.B.
2017-05-21 17:22 ` Jeffrey R. Carter
replies disabled

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