4 $DEBUG = false # This is a Global Variable Useful for MSG::debugging
6 ###########################################################################
8 ###########################################################################
11 def initialize(initvalue = 0)
17 MSG::debug("Acquire "+self.to_s)
18 Thread.critical = true
19 if (@counter -= 1) < 0
20 @waiting_list.push(Thread.current)
25 Thread.critical = false
29 MSG::debug("Release "+self.to_s)
30 Thread.critical = true
32 if (@counter += 1) <= 0
33 t = @waiting_list.shift
35 MSG::debug("Wakeup "+t.to_s)
37 MSG::debug("Nobody to wakeup")
44 Thread.critical = false
48 ########################################################################
50 ########################################################################
51 class MSG::Process < Thread
55 attr_reader :bind, :id ,:name # Read only
56 attr_accessor :properties, :pargs # R/W
62 raise "Bad Number Of arguments to create a a Ruby Process (name,args,prop) " if args.size < 3
64 @schedBegin = Semaphore.new(0)
65 @schedEnd = Semaphore.new(0)
66 #@properties = Hash.new()
82 # To be overriden by childs
83 raise("You must define a main() function in your process, containing the code of this process")
86 # Start : To keep the process alive and waiting via semaphore
89 # execute the main code of the process
90 MSG::debug("Begin execution")
92 processExit(self) # Exit the Native Process
98 #Get Bind ( Used > Native to Ruby)
103 #Get Binds (Used > Ruby to Native)
118 #C Simualator Process Equivalent Management
119 # After Binding Ruby Process to C Process
133 processIsSuspended(self)
141 # The Rest of Methods !!! To be Continued ...
144 #########################
146 #########################