5 $debug = true # This is a Global Variable Useful for Debugging
8 class RbProcess < Thread
15 attr_accessor :bind, :id, :proprieties, :name,
16 :pargs, :schedBegin, :schedEnd
23 # Used in ApplicationHandler to Initialize it
35 if argc == 0 #>>> new()
48 puts "Init Default Initialzer..."
51 # Thread.pass #yield ?!!
52 # sleep # Sleep Forever ... To Keep Thread Alive ?!!
58 # Initi with 2 arguments
60 if argc == 2 # >>>(HostName,Name) Or (Host , Name)
66 if ( type.to_s == "String")
67 host = Host.getByName(args[0])
70 if ( type.to_s == "MSG::Host")
80 raise "Process Name Cannot Be Null" if args[1].empty?
82 @name = args[1] # First Arg
89 @pargs = Array.new() # No Args[] Passed in Arguments
96 createProcess(self,host) #TODO >> MSG::Process
98 puts "Initilize with 2 args"
101 # sleep # Keep The Thread Runin'
108 # Init with 3 arguments
110 if argc == 3 #(hostName,Name,args[]) or # (Host,Name,args[])
113 type = args[0].type()
115 if( type.to_s == "String")
116 # host = Host.getByName(args[0])
117 host ="Host.getByName(args[0])"
120 if ( type.to_s == "MSG::Host" )
129 raise "Process Name Cannot Be Null" if args[0].empty?
133 type = args[2].type()
135 raise "Third Argument Should be an Array" if type != "Array"
141 @id = @@nextProcessId
145 createProcess(self,host) #TODO RubyMsg
148 puts "Initilize with 3 args"
151 # sleep #keep the thread running
158 # Init_var Called By Initialize
164 @proprieties = Hash.new()
165 # Process Synchronization Tools
166 @schedBegin = Semaphore.new(0)
167 @schedEnd = Semaphore.new(0)
178 return @@nextProcessId
191 Thread.list.each {|t| p t}
215 def processID(process)
232 def processName(process)
263 #C Simualateur Process Equivalent Management
264 # After Binding Ruby Process to C Process
283 processIsSuspended(self)
294 # The Rest of Methods !!! To be Continued ...