Re: Model Readers-Writers Problem
Dear, Ptolemy-Hackers, I work with Rendezvous Domain and don't understand clearly the behaviour of ResourcePool Actor. Edward Lee was so kind to answer on my previous questions, but one question remain obscure for me, why this model - http://files.rsdn.ru/39468/ResourcePoolWithDoubleSleep.xml - works deterministically ? ResourcePool must work nondeterministic. But at least all times I run this model, it's behaviour was deterministic. Is it a bug ? Thank you for help. Petrov Alexander Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Model Readers-Writers Problem
Thank you, it is very useful information for me. And in fact you've answered my previous letter question :) Only one question remain obscure for me, why this model - http://files.rsdn.ru/39468/ResourcePoolWithDoubleSleep.xml - works deterministically ? At least all times I run this model, it's behaviour was deterministic. Thank you for help. Petrov Alexander - - 2007/12/23, Edward A. Lee [EMAIL PROTECTED]: I can't quite parse the question, since all the text is run together in one big block, but it might be answered by just explaining how the rendezvous domain works. Any time an actor reads from an input port, it blocks until a rendezvous occurs. Non-domain-specific actors will always read from input ports in some order, depending on how they are written. Domain-specific actors (such as the merge actor that I used) can use more elaborate capabilities to indicate a willingness to rendezvous with any of several inputs. Edward Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Model Readers-Writers Problem
I think what you want is like the attached. Yes it is that, thank you. 2007/12/22, Edward A. Lee [EMAIL PROTECTED]: The display actor reads from all input channels in sequence, top to bottom. Is any actor (in the Rendezvous domain) reads from all input channels in that sequence ? And write ? In other words it is the rule in the Rendezvous domain ? For example ResourcePool actor should write the first resource in the pool to *any* grant output channel: From ResourcePool's documentation: * Then, in the calling thread, if there is at least one * resource in the pool, write the first resource in the pool * to any igrant/i output channel. But in the attached file, ResourcePool waits for writing to top channel, ResourcePool *could* write to bottom channel, but it waits for top and write to top. Why it is so ? I expect that it writes to bottom channel, because top channel actor is not ready, it sleeps. It seems like there is conflict between rule of sequencing writing to and reading from channels and ResourcePool's documentation. In you first model, it will want to participate in a multiway rendezvous with the top loop, then with the bottom. If those loops are not able to perform rendezvous in that order, then deadlock. In the second model, the Display has only one input channel and all participants linked via the relations will want to rendezvous at once. This model actually shouldn't be allowed in the Rendezvous domain because multiple output ports are connected to the same relation... This should be checked an exception should be thrown. The implementation may have an effect similar to the attached model, but who knows... Edward At 03:30 PM 12/21/2007, =?KOI8-R?B?8MXU0s/XIOHMxcvTwc7E0g==?= wrote: To Edward Lee: Thank you for your answer. Could somebody explain why that model - http://files.rsdn.ru/39468/ResourcePoolDeadlock.xml - is always hang (deadlocked) ? And why this model - http://files.rsdn.ru/39468/ResourcePoolOK.xml - is hang sometimes, but sometimes works. It seems to me, that when Display actor accepts some multiway rendezvous, he can't accepted another multiway rendezvous. And the chance that he accepts that or this rendezvous (up or bottom in the model ResourcePoolDeadlock) is depend on the order in which we connect Display Actor to Expression actors. Am I right ? I think so, because if I set Sleep2 value to 50L (and so value 3 should be displayed), Display actor nevertheless display value 2, from up Expression actor. But if I change the order, which I connected Expression actors to Display Actor and change the order of of connection Sleep actors to ResourcePool actors, than behaviour will be different. With all these refinements I think, that it might be more convenient to work with Rendezvous domain not in the Vergil, by directly using programming language (based on CSP and build in Ptolemy II, like Cal). Petrov Alexander 2007/12/22, Петров Александр [EMAIL PROTECTED]: -- Forwarded message -- From: Edward A. Lee [EMAIL PROTECTED] Date: 22.12.2007 0:45 Subject: Re: Model Readers-Writers Problem To: Петров Александр [EMAIL PROTECTED] Cc: ptolemy-hackers@bennett.eecs.berkeley.edu Rendezvous is a good domain for modeling mutual exclusion as well as other resource management problems. The ResourcePool demo in that domain illustrates this. Edward At 12:32 PM 12/21/2007, =?KOI8-R?B?8MXU0s/XIOHMxcvTwc7E0g==?= wrote: Hello, Ptolemy Hackers, I struggle with modelling reader-writer sample. This sample assumes that there is something like shared state. And the problem is to model mutual exclusion between Reader - Writer, and between Writer - Writer. So I have to model shared state in purely message-passing, actor-oriented framework PtolemyII. Only think I've found to do that is parameters, that global for model and that can be read and written by Expression actor. But it seems like workaround to the problem. Does anybody has sample (in any Domains (with any Directors)) modelling Readers-Writers problem ? Or some ideas how achieve that in Ptolemy II. Thank you. Petrov Alexander [EMAIL PROTECTED] Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Edward A. Lee Chair of EECS and Robert S. Pepper Distinguished Professor 231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770 phone: 510-642-0253, fax: 510-642-2845 [EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Edward A. Lee Chair of EECS and Robert S. Pepper Distinguished Professor 231 Cory
Re: Model Readers-Writers Problem
To be more concret, near I place all three models, and all these models have the same structure and different behaviour: http://files.rsdn.ru/39468/ResourcePoolDeadlock1.xml http://files.rsdn.ru/39468/ResourcePoolDeadlock2.xml http://files.rsdn.ru/39468/ResourcePoolDeadlock3.xml 2007/12/22, Петров Александр [EMAIL PROTECTED]: To Edward Lee: Thank you for your answer. Could somebody explain why that model - http://files.rsdn.ru/39468/ResourcePoolDeadlock.xml - is always hang (deadlocked) ? And why this model - http://files.rsdn.ru/39468/ResourcePoolOK.xml - is hang sometimes, but sometimes works. It seems to me, that when Display actor accepts some multiway rendezvous, he can't accepted another multiway rendezvous. And the chance that he accepts that or this rendezvous (up or bottom in the model ResourcePoolDeadlock) is depend on the order in which we connect Display Actor to Expression actors. Am I right ? I think so, because if I set Sleep2 value to 50L (and so value 3 should be displayed), Display actor nevertheless display value 2, from up Expression actor. But if I change the order, which I connected Expression actors to Display Actor and change the order of of connection Sleep actors to ResourcePool actors, than behaviour will be different. With all these refinements I think, that it might be more convenient to work with Rendezvous domain not in the Vergil, by directly using programming language (based on CSP and build in Ptolemy II, like Cal). Petrov Alexander 2007/12/22, Петров Александр [EMAIL PROTECTED]: -- Forwarded message -- From: Edward A. Lee [EMAIL PROTECTED] Date: 22.12.2007 0:45 Subject: Re: Model Readers-Writers Problem To: Петров Александр [EMAIL PROTECTED] Cc: ptolemy-hackers@bennett.eecs.berkeley.edu Rendezvous is a good domain for modeling mutual exclusion as well as other resource management problems. The ResourcePool demo in that domain illustrates this. Edward At 12:32 PM 12/21/2007, =?KOI8-R?B?8MXU0s/XIOHMxcvTwc7E0g==?= wrote: Hello, Ptolemy Hackers, I struggle with modelling reader-writer sample. This sample assumes that there is something like shared state. And the problem is to model mutual exclusion between Reader - Writer, and between Writer - Writer. So I have to model shared state in purely message-passing, actor-oriented framework PtolemyII. Only think I've found to do that is parameters, that global for model and that can be read and written by Expression actor. But it seems like workaround to the problem. Does anybody has sample (in any Domains (with any Directors)) modelling Readers-Writers problem ? Or some ideas how achieve that in Ptolemy II. Thank you. Petrov Alexander [EMAIL PROTECTED] Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Edward A. Lee Chair of EECS and Robert S. Pepper Distinguished Professor 231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770 phone: 510-642-0253, fax: 510-642-2845 [EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]