* Requeue @ 2002-04-07 22:50 Anatoly Chernyshev 2002-04-08 3:40 ` Requeue Pat Rogers ` (3 more replies) 0 siblings, 4 replies; 13+ messages in thread From: Anatoly Chernyshev @ 2002-04-07 22:50 UTC (permalink / raw) Hello, everybody, Actually, this question is for Ada gurus. I've read in two places (Coronado tutorial and J. English's "The craft of object oriented programming") that there is a reserved word "requeue" used in task programming, but this is so much advanced, tricky and deep technique that it isn't even worthy of mention. So, eventually I've got concerned about what is this word used for. Could someone post a simple yet practical example of using that statement in Ada programming? Thanks in advance, Anatoly ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-07 22:50 Requeue Anatoly Chernyshev @ 2002-04-08 3:40 ` Pat Rogers 2002-04-08 5:00 ` Requeue Robert Dewar ` (2 subsequent siblings) 3 siblings, 0 replies; 13+ messages in thread From: Pat Rogers @ 2002-04-08 3:40 UTC (permalink / raw) "Anatoly Chernyshev" <rhezusfactor@yahoo.com> wrote in message news:3CB0CD37.52B43088@yahoo.com... > Hello, everybody, > > Actually, this question is for Ada gurus. I've read in two places > (Coronado tutorial and J. English's "The craft of object oriented > programming") that there is a reserved word "requeue" used in task > programming, but this is so much advanced, tricky and deep technique > that it isn't even worthy of mention. So, eventually I've got concerned > about what is this word used for. > Could someone post a simple yet practical example of using that > statement in Ada programming? Think of various tasks interacting in a client-server organization. These tasks synchronize and communicate via the language's mechanisms to implement this relationship, in which client tasks request a service of the server task. For example, imagine a server task that allocates discrete resources upon request. These resources can be anything, but there is a finite number of them. As such, not all requests can be satisfied when received, for example because the requested allocation is larger than the amount currently available. One way to program this is to use a form of synchronization in which the client is held pending when a request cannot be satisfied. In this approach, the server has determined that the request cannot be satisfied and simply suspends the caller in the middle of the service request. Eventually (presumably) some other event will occur, such that the pending request can now be satisfied, and the service resumes for the original caller. The primary characteristic is that the server suspends the service execution on behalf of the client until the request can be satisfied. ("Condition variables" are a way of implementing this approach. This can be messy but it works.) Ada uses "avoidance synchronization", which means that the service requested is not supposed to start before the request can be fulfilled. That's a problem for Ada's mechanisms because they use the parameters of the synchronization mechanism to communicate the requested allocation -- but there is no way to read the parameters until the mechanism executes, so it is too late to stop if the request cannot be fulfilled. (The guards on select statements, for example, cannot refer to the formal parameters of accept statements.) In Ada 83 this led to a two-rendezvous approach -- one to get the request via the parameters, and a second to actually satisfy the request when the conditions allow. That's both inefficient and open to issues of abort: what if the second call never comes in? So, enter the requeue statement for Ada 95. You can think of a requeue as being similar to what happens when you call a large corporation. The first person to answer is a receptionist -- they have no idea how to handle your request, but they can send you to the person who does, so they forward your call to the proper person and then hang up. The receptionist is done with you, and can go on to answer the next incoming call. But from your point of view, you've made one call and are now waiting for the other person to answer your (forwarded) call. You've been requeued. There are other details, such as being able to say whether or not abort is deferred, but that is the gist of it. I recommend this book for concurrent programming with Ada: A. Burns and A. J. Wellings, Concurrency In Ada, Second ed: Cambridge University Press, 1998. It talks about this issue -- and any other aspect of concurrency in Ada -- in lucid detail. You can find examples there too. Hope that helps, --- Patrick Rogers Consulting and Training in: http://www.classwide.com Real-Time/OO Languages progers@classwide.com Hard Deadline Schedulability Analysis (281)648-3165 Software Fault Tolerance ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-07 22:50 Requeue Anatoly Chernyshev 2002-04-08 3:40 ` Requeue Pat Rogers @ 2002-04-08 5:00 ` Robert Dewar 2002-04-09 10:27 ` Requeue Ehud Lamm 2002-04-09 16:01 ` Requeue Darren New 2002-04-09 17:52 ` Requeue Anatoly Chernyshev 3 siblings, 1 reply; 13+ messages in thread From: Robert Dewar @ 2002-04-08 5:00 UTC (permalink / raw) Anatoly Chernyshev <rhezusfactor@yahoo.com> wrote in message news:<3CB0CD37.52B43088@yahoo.com>... > Could someone post a simple yet practical example of > using that statement in Ada programming? That's what the rationale is for, always look there first! ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-08 5:00 ` Requeue Robert Dewar @ 2002-04-09 10:27 ` Ehud Lamm 0 siblings, 0 replies; 13+ messages in thread From: Ehud Lamm @ 2002-04-09 10:27 UTC (permalink / raw) "Robert Dewar" <dewar@gnat.com> wrote in message news:5ee5b646.0204072100.1f3707a0@posting.google.com... > Anatoly Chernyshev <rhezusfactor@yahoo.com> wrote in message news:<3CB0CD37.52B43088@yahoo.com>... > > Could someone post a simple yet practical example of > > using that statement in Ada programming? > > That's what the rationale is for, always look there first! Right! This is always true, and requeue is explained beautifully in the Rationale. It may be useful to keep in mind that Requeue can be used to solve radically different problems. It may be best to try and understand each type of use, as explained in the rationale, separately. Suddenly the Aha moment will come when you see why all these different things can be done using requeue. Ehud Lamm ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-07 22:50 Requeue Anatoly Chernyshev 2002-04-08 3:40 ` Requeue Pat Rogers 2002-04-08 5:00 ` Requeue Robert Dewar @ 2002-04-09 16:01 ` Darren New 2002-04-09 17:52 ` Requeue Anatoly Chernyshev 3 siblings, 0 replies; 13+ messages in thread From: Darren New @ 2002-04-09 16:01 UTC (permalink / raw) Anatoly Chernyshev wrote: > Could someone post a simple yet practical example of using that > statement in Ada programming? Part of the need for requeue comes from the fact that a guard can't be based on the parameters of the call. So if I want to do something like entry Save_In_Buffer(Octets : in Stream_Element_Array) when Octets'Length < My_Buffer.Remaining_Space is begin .... end Save_In_Buffer; I can't do that. Octets'Length isn't allowed in the guard. So instead I do entry Save_In_Buffer(...) when True is begin if My_Buffer.Remaining_Space < Octets'Length then requeue Save_Wait end if; ... end Save_In_Buffer; Then Save_Wait has a guard that is gets set to false whenever I put something into the buffer and true whenever I take something out. Inside Save_Wait, once you get in, you check again, and if there's still no room, you requeue once again. Ugly but it works. I'd be happy to put the code somewhere if you want to look. -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand. Remember, drive defensively if you drink. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-07 22:50 Requeue Anatoly Chernyshev ` (2 preceding siblings ...) 2002-04-09 16:01 ` Requeue Darren New @ 2002-04-09 17:52 ` Anatoly Chernyshev 2002-04-09 18:28 ` Requeue Larry Kilgallen 3 siblings, 1 reply; 13+ messages in thread From: Anatoly Chernyshev @ 2002-04-09 17:52 UTC (permalink / raw) Thanks a lot for your answers - they were extremely helpful. What abou reading rationale - that is true, I had to read it. But then, why don't one to close this newsgroup and leave just universal notice with large bold letters "RTFM" in it? Regards, Anatoly. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 17:52 ` Requeue Anatoly Chernyshev @ 2002-04-09 18:28 ` Larry Kilgallen 2002-04-09 20:06 ` Requeue Anatoly Chernyshev 0 siblings, 1 reply; 13+ messages in thread From: Larry Kilgallen @ 2002-04-09 18:28 UTC (permalink / raw) In article <3CB32A54.A3A9E975@yahoo.com>, Anatoly Chernyshev <rhezusfactor@yahoo.com> writes: > Thanks a lot for your answers - they were extremely helpful. > What abou reading rationale - that is true, I had to read it. > But then, why don't one to close this newsgroup and leave just universal > notice with large bold letters "RTFM" in it? The fact that requeue is dealt with in the Rationale does not mean that _all_ Ada questions are handled there. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 18:28 ` Requeue Larry Kilgallen @ 2002-04-09 20:06 ` Anatoly Chernyshev 2002-04-09 20:47 ` Requeue Marin David Condic ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Anatoly Chernyshev @ 2002-04-09 20:06 UTC (permalink / raw) > The fact that requeue is dealt with in the Rationale does not > mean that _all_ Ada questions are handled there. Well, then they are explained elsewhere. Otherwise, how the people knows these things. By "FM" I understood not only Rationale, but any publication one could peep into. Merely publish the list of references in CLA and sleep in rest. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 20:06 ` Requeue Anatoly Chernyshev @ 2002-04-09 20:47 ` Marin David Condic 2002-04-09 21:15 ` Requeue Pat Rogers 2002-04-09 21:22 ` Requeue Ehud Lamm 2 siblings, 0 replies; 13+ messages in thread From: Marin David Condic @ 2002-04-09 20:47 UTC (permalink / raw) Hmmmmmmm..... Seems a little out of geek character to pass up on an opportunity to demonstrate superior knowlege in all subjects. :-) Sort of like passing up a chance to get a calculator with even more buttons on it. Usually, one can toss a question out here and get some really great condescention with an answer in it somewhere as in "Its intuitively obvious to even the most casual observer that blah blah blah, you eediot!!!!" to which, the proper response is "My cheeks burn with shame at the display of your superior intellect..." or something equally obsequious. Its sort of the price one pays for "free" consulting. :-) MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com "Anatoly Chernyshev" <rhezusfactor@yahoo.com> wrote in message news:3CB349CB.7CF3391A@yahoo.com... > > Well, then they are explained elsewhere. Otherwise, how the people knows these things. > By "FM" I understood not only Rationale, but any publication one could peep into. > Merely publish the list of references in CLA and sleep in rest. > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 20:06 ` Requeue Anatoly Chernyshev 2002-04-09 20:47 ` Requeue Marin David Condic @ 2002-04-09 21:15 ` Pat Rogers 2002-04-09 21:43 ` Requeue Anatoly Chernyshev 2002-04-09 21:22 ` Requeue Ehud Lamm 2 siblings, 1 reply; 13+ messages in thread From: Pat Rogers @ 2002-04-09 21:15 UTC (permalink / raw) "Anatoly Chernyshev" <rhezusfactor@yahoo.com> wrote in message news:3CB349CB.7CF3391A@yahoo.com... > > > > > The fact that requeue is dealt with in the Rationale does not > > mean that _all_ Ada questions are handled there. > > Well, then they are explained elsewhere. Otherwise, how the people knows these things. > By "FM" I understood not only Rationale, but any publication one could peep into. > Merely publish the list of references in CLA and sleep in rest. Ya nye penemiyu. I gave you a rather lengthy intro to the requeue semantics as well as a pointer to a good textbook dedicated to concurrency with Ada. Others did as well. The Rationale would have been a good thing for me to have included, and it is not the "FM", so are you complaining about someone pointing you to the Rationale, and, if so why? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 21:15 ` Requeue Pat Rogers @ 2002-04-09 21:43 ` Anatoly Chernyshev 2002-04-10 2:18 ` Requeue Pat Rogers 0 siblings, 1 reply; 13+ messages in thread From: Anatoly Chernyshev @ 2002-04-09 21:43 UTC (permalink / raw) > Ya nye penemiyu. I gave you a rather lengthy intro to the requeue semantics as > well as a pointer to a good textbook dedicated to concurrency with Ada. Others > did as well. The Rationale would have been a good thing for me to have > included, and it is not the "FM", so are you complaining about someone pointing > you to the Rationale, and, if so why? Poimite zhe nakonec. I appreciate your efforts (frankly, no kidding) and comments of other people and I'm not complaining a bit. I simply issued a distracted remark (mainly in response to R. Dewar's post) meaning that everyone could become Ada guru just pointing others to Rationale and if people will always follow his advice, there will be no need for CLA. Especially for periodically arisen questions like "How to convert integer to string". But I never expected that great programmers are so offensive. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 21:43 ` Requeue Anatoly Chernyshev @ 2002-04-10 2:18 ` Pat Rogers 0 siblings, 0 replies; 13+ messages in thread From: Pat Rogers @ 2002-04-10 2:18 UTC (permalink / raw) "Anatoly Chernyshev" <rhezusfactor@yahoo.com> wrote in message news:3CB36065.1BC7FF6B@yahoo.com... > > Ya nye penemiyu. I gave you a rather lengthy intro to the requeue semantics as > > well as a pointer to a good textbook dedicated to concurrency with Ada. Others > > did as well. The Rationale would have been a good thing for me to have > > included, and it is not the "FM", so are you complaining about someone pointing > > you to the Rationale, and, if so why? > > Poimite zhe nakonec. I appreciate your efforts (frankly, no kidding) and comments of > other people and I'm not complaining a bit. > I simply issued a distracted remark (mainly in response to R. Dewar's post) meaning > that everyone could become Ada guru just pointing others to Rationale and if people > will always follow > his advice, there will be no need for CLA. Especially for periodically arisen > questions like "How to convert integer to string". > But I never expected that great programmers are so offensive. I'm sure he meant no offense; I was remiss in not mentioning the Rationale to you myself. Definitely worth reading because (by definition) it explains why the language contains what it does, which helps people use the language well. I very much appreciated "Studies In Ada Style" (for Ada 83) for the same reason. Best regards, Pat ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Requeue 2002-04-09 20:06 ` Requeue Anatoly Chernyshev 2002-04-09 20:47 ` Requeue Marin David Condic 2002-04-09 21:15 ` Requeue Pat Rogers @ 2002-04-09 21:22 ` Ehud Lamm 2 siblings, 0 replies; 13+ messages in thread From: Ehud Lamm @ 2002-04-09 21:22 UTC (permalink / raw) > Well, then they are explained elsewhere. Otherwise, how the people knows these things. > By "FM" I understood not only Rationale, but any publication one could peep into. > Merely publish the list of references in CLA and sleep in rest. When someone asks for a simple and practical code example, I don't see much harm in pointing him to the Rationale (which is available online). Ehud ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2002-04-10 2:18 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-04-07 22:50 Requeue Anatoly Chernyshev 2002-04-08 3:40 ` Requeue Pat Rogers 2002-04-08 5:00 ` Requeue Robert Dewar 2002-04-09 10:27 ` Requeue Ehud Lamm 2002-04-09 16:01 ` Requeue Darren New 2002-04-09 17:52 ` Requeue Anatoly Chernyshev 2002-04-09 18:28 ` Requeue Larry Kilgallen 2002-04-09 20:06 ` Requeue Anatoly Chernyshev 2002-04-09 20:47 ` Requeue Marin David Condic 2002-04-09 21:15 ` Requeue Pat Rogers 2002-04-09 21:43 ` Requeue Anatoly Chernyshev 2002-04-10 2:18 ` Requeue Pat Rogers 2002-04-09 21:22 ` Requeue Ehud Lamm
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox