From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,41967527237c1aa2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!b75g2000hsg.googlegroups.com!not-for-mail From: mhamel_98@yahoo.com Newsgroups: comp.lang.ada Subject: Re: Fun with Tasking Date: 29 Mar 2007 08:17:34 -0700 Organization: http://groups.google.com Message-ID: <1175181454.290582.90280@b75g2000hsg.googlegroups.com> References: <1175097196.113031.259000@r56g2000hsd.googlegroups.com> <1175100948.580216.145940@r56g2000hsd.googlegroups.com> <1175104396.231171.125360@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: 155.104.37.17 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1175181455 12124 127.0.0.1 (29 Mar 2007 15:17:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 29 Mar 2007 15:17:35 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MathPlayer 2.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: b75g2000hsg.googlegroups.com; posting-host=155.104.37.17; posting-account=RO8m9AwAAAB418WhNxD6U0JmFC9jLoK1 Xref: g2news1.google.com comp.lang.ada:14666 Date: 2007-03-29T08:17:34-07:00 List-Id: On Mar 29, 12:59 am, "Jeffrey R. Carter" wrote: > mhamel...@yahoo.com wrote: > > > Thank you Adam. While making this sample program a sneaking suspicion > > started to creep up that I really didn't know what I was doing, and > > you helped verify that suspicion. What's really going on is I have a > > number of tasks I'm going to run, and while themselves completely > > independent of one another, they send updates to a single listening, > > or collating, task. That is the task at the heart of my initial > > post. My approach was to start up this collating task and give it's > > pointer (or address) to the processing tasks. This works fine if the > > collating task definition is in the acc_add_test procedure and the > > Control_Block has a pointer to that task within it. However, I would > > like the collating task definition to reside with the "exec" procedure/ > > package as the sample has it. How would one declare and start up that > > task, without any visibility into the package, just a procedure > > pointer with a mode argument? My (terribly flawed) idea was the > > PreProcess element of the procedure would set that up, but as you > > pointed out, the procedure would never exit while the task is > > running. So how to define the task and put it on "hold" until the > > processing tasks can utilize it? I don't expect it's possible without > > incurring as much ugliness as the program has already, but I thought > > I'd give it a try. Thanks again =) > > Tasking /is/ fun. I seem to be unusual in that I don't find it > difficult. I'd like to be able to show off and solve all your problems, > but I still have no idea what you're trying to achieve. I've got a lot > of information about how you're trying to implement it, but no idea what > "it" is. If you can describe the problem, there's probably an elegant > way to implement a solution in Ada. > > -- > Jeff Carter > "All citizens will be required to change their underwear > every half hour. Underwear will be worn on the outside, > so we can check." > Bananas > 29- Hide quoted text - > > - Show quoted text - Great help and advice all around, thanks much c.l.a! Anyhoo Jeff, I'll try to explain in more detail what my program is doing and hopefully you can see where I'm going wrong. The program has a number of packages, each handling what I call a subsystem, to be verbose: ephemeris, residual, vector, covariance and a few others (this sort of equates to the "exec" procedure in my sample). Each of these systems has a number of procedures of interest, like a differencing of quantities, a statistical analysis, etc. Now each of these procedures of each of these subsystems can have up to 60 (and more as we go on) objects - each one I handle as it's own task. I've found that throwing 60 threads at the OS (W2K in this case) is, while better then serially and single-threaded on multi-cpu's, not terribly efficient. For this application, I've found most procedures operate best if N+1 threads are running, N being the processors available. The output is all .csv files. For awhile, to show an ensemble of data, I would do a lot of cut and pasting between .csv's, one day, I thought, why not have the program do this? So I implemented these "collating" tasks that all 60 or so threads would send some information to for some sort of unified processing. Each procedure of each subsystem/package is slightly different either in the data types being handled or the manner in which the data is processed so a "generic" collating task isn't really feasible. That's what's happening, now how do I handle it? As the program starts, I have each subsystem loads its procedures (via procedure pointers) to a task manager. A command is recieved via CLI and the task manager then inserts, let's say, 60 copies of a specified procedure into a list which are doled out to worker threads so that only N+1 are active at any time. The issue I'm having is, how do you have a unique collating task created for those 60 processes to send updates to? As it is now, I have all of these (nearly a dozen) unique collating tasks defined in the task manager. I would rather have them defined in the subsystem package to which they really belong. As the subsystem packages "push" their procedures to the task manager, the task manager has no visibility into the subsystem. My aim was to define an area (a System.Address for example) in a control block record that the task manager would have space for "a task". What this task was, what it did, where it came from the task manager would not know nor care, but it would be the owner, or master, in some sense so the "preprocess" or initialization component could exit. I hope this makes a little sense.