|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
This defines the interface to a process controller.
BE SURE to .init() this controller BEFORE any other threads access its methods (particularly execute()). Some implementations my be bases on Threads. Be sure to .start() after init() Failure to heed this warning COULD result in a race condition... :-)
There are four "commands" to a process controller: - PAUSE will hold execution - RESUME will restart execution - STOP will stop execution of the VM and dump it - KILL will stop the execution and let this process die!
EPG - New - 24Jul03 | Method Summary | |
boolean |
execute(VM aVM)
Load and Execute a VM. |
int |
getPID()
Get's the PID for this process |
java.lang.String |
getRootProgram()
Get's root program |
int |
getState()
A simple request for state. |
SystemContext |
getSystemContext()
Get my system context. |
void |
init(SystemContext sctx,
int setpid)
Initialize the process controller. |
void |
joinIt()
Join the process |
boolean |
kill()
Kill this context. |
java.lang.Object |
processAttribute(java.lang.String name)
Get a registered process attribute. |
void |
run()
Run the process. |
void |
start()
Run the process. |
int |
verifyState()
Verify the state of the VM. |
boolean |
vmPause()
Pause the vm. |
boolean |
vmResume()
Resume the vm. |
boolean |
vmStop()
Stop the vm. |
| Method Detail |
public void init(SystemContext sctx,
int setpid)
throws VMException
sctx - a ready SystemContext. This will be fed to all controlled processes.setpid - the pid
VMException - is the process goes badVMpublic boolean execute(VM aVM)
This method can be called by any thread. It will clear the request flags.
aVM - A fully implimented derived-class of VM.
VMpublic boolean vmPause()
There is no rendezvous; the method will not block. All successive requests count as the same request until the context services it. There is no guarentee on the timing of the service. The Context will not check for requests until AFTER the current instruction is complete. So, if the vm is executing a long wait instruction, it could indeed be some time before the request is serviced.
If you need to make sure that the request worked, then use the verifyState() method to get the definative state of the VM/Context.
As for the return value, "success" merely means that the request was successfully posted and not that the action was completed.
One last thaught: this is not a robust OS implimentation of a thread context. You might want to restrict calls to vmPause() and vmResume() to a single external thread. Multiple threads might get confused if they don't cooperate...
VMpublic boolean vmResume()
See the notes for the pause() method.
VMpublic boolean vmStop()
See the notes for the pause() method.
VMpublic int getPID()
public java.lang.String getRootProgram()
public boolean kill()
See the notes for the pause() method.
VMpublic int verifyState()
(And, never EVER call this method from within THIS thread. You'll almost certainly deadlock it.)
The following describes each state:
STATE_NEW = VM is loaded bu not started
STATE_RUNNING = VM is actively running.
STATE_PAUSED = VM is paused.
STATE_DONE = VM finished execution.
This is rare, as the VM will
be automatically unloaded when
finished.
STATE_NO_VM = No VM is loaded into this context.
VMpublic int getState()
VMpublic SystemContext getSystemContext()
VMpublic java.lang.Object processAttribute(java.lang.String name)
VMpublic void run()
public void start()
public void joinIt()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||