Re: help me.



Responding to Wu...

If I post in wrong place. forgive me.
I hope some one can Refactor following code for me!
We have a system with 6 application. One application (Named it
ContrlPanel) is a control center, it get command from UI and order
other application do some work. All these application communicate with
each other through share memory. so now all job of ControlPanel is like
following.
1. poll the state of A.
2. according to the state of A order B to do something.
3. poll the state of C.
4. according to the state of C order E or F to do something.
because all this job with share memory need do again and again till
succeed.(try to lock it etc).
so we get some code like following
XXXXThread
{
while (!exit)
{
switch(state) {
case GETING_A_STATE:
if (GetAState()) {
state = DOING_SOMETHING_A;
}
break;
case DOING_SOMETHING_A:
if (DoSomeA()) {
state = GET_C_STATE;
}
break;
case GET_C_STATE:
....
}
}
}

How does 'exit' get set? Is that related to why the loop was done this way? (I assume it is just bound to a register that indicates whether shared memory is locked.)

It seems to me this is just overcomplicating things. It is also using 'state' to describe two different kinds of conditions and that sort of overloading is usually fragile. So I would try a simpler polling loop:

while (!exit)
{
if (GetAState())
DoSomeA()
if (GetCState())
DoSomeC()
...
}


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH



.



Relevant Pages

  • help me.
    ... I hope some one can Refactor following code for me! ... ContrlPanel) is a control center, it get command from UI and order ... each other through share memory. ... poll the state of A. ...
    (comp.object)
  • help me.
    ... I hope some one can Refactor following code for me! ... ContrlPanel) is a control center, it get command from UI and order ... each other through share memory. ... poll the state of A. ...
    (comp.object)
  • help me.
    ... I hope some one can Refactor following code for me! ... ContrlPanel) is a control center, it get command from UI and order ... each other through share memory. ... poll the state of A. ...
    (comp.object)
  • please help me.
    ... ContrlPanel) is a control center, it get command from UI and order ... each other through share memory. ... poll the state of A. ... this kind of source code make me sick. ...
    (comp.programming.threads)
  • Re: Oracle memory allocation on Linux 2.6
    ... direct I/O should lower memory consumption simply because it ... bypasses buffer cache over which we have no control. ... With Linux, I really have a problem with the ... as well as system administrators are ...
    (comp.databases.oracle.server)