summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3a9b798)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7193
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
VALUE rb_task_receive(VALUE class, VALUE mailbox) {
// Task
m_task_t task = NULL;
VALUE rb_task_receive(VALUE class, VALUE mailbox) {
// Task
m_task_t task = NULL;
- INFO1("Receiving a task on mailbox '%s'",RSTRING(mailbox)->ptr);
+ INFO2("Receiving a task on mailbox '%s', store it into %p",RSTRING(mailbox)->ptr,&task);
MSG_task_receive(&task,RSTRING(mailbox)->ptr);
INFO2("XXXXXXXXReceived a task %p %s",task,task->name);
return Data_Wrap_Struct(class, 0, rb_task_free, task);
MSG_task_receive(&task,RSTRING(mailbox)->ptr);
INFO2("XXXXXXXXReceived a task %p %s",task,task->name);
return Data_Wrap_Struct(class, 0, rb_task_free, task);
require 'simgrid_ruby'
require 'thread'
require 'simgrid_ruby'
require 'thread'
-$DEBUG = false # This is a Global Variable Useful for MSG::debugging
-
###########################################################################
# Class Semaphore
###########################################################################
###########################################################################
# Class Semaphore
###########################################################################
- MSG::debug(Thread.current.to_s+" acquires "+self.to_s)
Thread.critical = true
if (@counter -= 1) < 0
Thread.critical = true
if (@counter -= 1) < 0
+ MSG::debug(Thread.current.to_s+" acquires "+self.to_s+". That's blocking.")
@waiting_list.push(Thread.current)
Thread.stop
@waiting_list.push(Thread.current)
Thread.stop
+ else
+ MSG::debug(Thread.current.to_s+" acquires "+self.to_s+". It was free.")
- MSG::debug(Thread.current.to_s+" releases "+self.to_s)
Thread.critical = true
begin
if (@counter += 1) <= 0
t = @waiting_list.shift
t.wakeup if t
Thread.critical = true
begin
if (@counter += 1) <= 0
t = @waiting_list.shift
t.wakeup if t
- MSG::debug("Wakeup "+t.to_s)
+ MSG::debug(Thread.current.to_s+" releases "+self.to_s+". Wakeup "+t.to_s)
- MSG::debug("Nobody to wakeup")
+ MSG::debug(Thread.current.to_s+" releases "+self.to_s+". Nobody to wakeup")
end
rescue ThreadError
retry
end
rescue ThreadError
retry
def initialize(*args)
super(){
def initialize(*args)
super(){
- raise "Bad Number Of arguments to create a Ruby Process (name,args,prop) " if args.size < 3
+ raise "Bad number of arguments to create a Ruby process. Expected (name,args,prop) " if args.size < 3
# @cv = ConditionVariable.new
# @mutex = Mutex.new
# @cv = ConditionVariable.new
# @mutex = Mutex.new
def main(args)
# To be overriden by childs
raise("You must define a main() function in your process, containing the code of this process")
end
def main(args)
# To be overriden by childs
raise("You must define a main() function in your process, containing the code of this process")
end
- # Start : To keep the process alive and waiting via semaphore
def start()
@schedBegin.acquire()
def start()
@schedBegin.acquire()
- # execute the main code of the process
- MSG::debug("Begin execution")
+ MSG::debug("Let's execute the main() of the Ruby process")
main(@pargs)
# processExit(self) # Exit the Native Process
@schedEnd.release()
main(@pargs)
# processExit(self) # Exit the Native Process
@schedEnd.release()
-# FIXME : this methode should be associated to the class !! it reurn a task
+# FIXME : this method should be associated to the class !! it return a task
+# FIXME: simply killing this adapter method should do the trick
def receive(mailbox)
super(self,mailbox)
end
def receive(mailbox)
super(self,mailbox)
end
def listenFromHost(t_alias,host)
super(t_alias,host)
end
def listenFromHost(t_alias,host)
super(t_alias,host)
end
end
############################################
end
############################################
end
#########################
end
#########################