5 $debug = true # This is a Gloabl Variable Useful for Debbuging
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")
68 host = Host.getByName(args[0])
72 if ( type.to_s == "MSG::Host")
84 raise "Process Name Cannot Be Null" if args[1].empty?
86 @name = args[1] # First Arg
93 @pargs = Array.new() # No Args[] Passed in Arguments
100 createProcess(self,host) #TODO >> MSG::Process
102 puts "Initilize with 2 args"
105 # sleep # Keep The Thread Runin'
112 # Init with 3 arguments
114 if argc == 3 #(hostName,Name,args[]) or # (Host,Name,args[])
117 type = args[0].type()
119 if( type.to_s == "String")
120 # host = Host.getByName(args[0])
121 host ="Host.getByName(args[0])"
124 if ( type.to_s == "MSG::Host" )
133 raise "Process Name Cannot Be Null" if args[0].empty?
137 type = args[2].type()
139 raise "Third Argument Should be an Array" if type != "Array"
145 @id = @@nextProcessId
149 createProcess(self,host) #TODO RubyMsg
152 puts "Initilize with 3 args"
155 # sleep #keep the thread running
162 # Init_var Called By Initialize
168 @proprieties = Hash.new()
169 # Process Synchronization Tools
170 @schedBegin = Semaphore.new(0)
171 @schedEnd = Semaphore.new(0)
182 return @@nextProcessId
195 Thread.list.each {|t| p t}
219 def processID(process)
236 def processName(process)
267 #C Simualateur Process Equivalent Management
268 # After Binding Ruby Process to C Process
287 processIsSuspended(self)
298 # The Rest of Methods !!! To be Continued ...