1 # FIXME: add license like in C files
6 $DEBUG = false # This is a Global Variable Useful for MSG::debugging
8 ###########################################################################
10 ###########################################################################
13 def initialize(initvalue = 0)
19 MSG::debug("Acquire "+self.to_s)
20 Thread.critical = true
21 if (@counter -= 1) < 0
22 @waiting_list.push(Thread.current)
27 Thread.critical = false
31 MSG::debug("Release "+self.to_s)
32 Thread.critical = true
34 if (@counter += 1) <= 0
35 t = @waiting_list.shift
37 MSG::debug("Wakeup "+t.to_s)
39 MSG::debug("Nobody to wakeup")
46 Thread.critical = false
50 ########################################################################
52 ########################################################################
53 class MSG::Process < Thread
57 attr_reader :bind, :id, :name, :pargs ,:properties# Read only
62 raise "Bad Number Of arguments to create a Ruby Process (name,args,prop) " if args.size < 3
64 @schedBegin = Semaphore.new(0)
65 @schedEnd = Semaphore.new(0)
66 #@properties = Hash.new() FIXME: get this from the C (yep that makes 4 args to this function)
67 @id = @@nextProcessId++
77 # To be overriden by childs
78 raise("You must define a main() function in your process, containing the code of this process")
81 # Start : To keep the process alive and waiting via semaphore
84 # execute the main code of the process
85 MSG::debug("Begin execution")
87 # processExit(self) # Exit the Native Process
122 processIsSuspended(self)
129 # The Rest of Methods !!! To be Continued ... FIXME: what's missing?
132 ############################################
133 # Task Extend from the native Class RbTask
134 ############################################
135 class MSG::Task < MSG::RbTask
137 def initialize(*args)
173 def listenFromHost(t_alias,host)
179 ############################################
180 # Host Extend from the native Class RbHost
181 ############################################
182 class MSG::Host < MSG::RbHost
214 #########################
216 #########################