In DCE the register signal handler not getting call after specified time expire in the POSIX implementation of timer_create

44 views
Skip to first unread message

Jayasantosh Samal

unread,
Apr 12, 2017, 4:11:29 AM4/12/17
to ns-3-users, Randy....@landisgyr.com, Ruben....@landisgyr.com, vishal...@landisgyr.com
During use of timer_create in DCE environment , am facing issue like the signal handler is not invoke after specified time  get expire. I have attached two file, one is my DCE script(Sbsn.cc) and other is my timer application(sm-v.c) file.I have run DCE script in both  virtual time and real time. Below steps doing in timer application and DCE script.

Step 1: Registering a signal handler inside  timer application.
            int                     sigNo = SIGUSR1;            
            sa.sa_flags = SA_SIGINFO;
            sa.sa_sigaction = timerHandler;
            sigemptyset(&sa.sa_mask);
            sigaction(sigNo, &sa, NULL);

Step 2: Creating timer and Set and enable alarm.
            te.sigev_notify = SIGEV_SIGNAL;
            te.sigev_signo = sigNo;
            te.sigev_value.sival_ptr = &timerID;
            timer_create(CLOCK_REALTIME, &te, &timerID);
            
Step 3: Set time in timer
              its.it_interval.tv_sec = (time_t)(intervalMS/ 1000L);
              its.it_interval.tv_nsec = intervalMS % 1000000;
              its.it_value.tv_sec = (time_t)(intervalMS/ 1000L);
              its.it_value.tv_nsec = intervalMS % 1000000;   
              timer_settime(timerID,0, &its, NULL);

Step 4: Registering timer application inside the DCE script.
            dce.SetBinary ("SbsTimer");

   

I  have done some home work by looking into dce_timer_create() and dce_timer_settime() function inside dce-time.cc. I have found out that dce_timer_create() is not using the signal structure(struct sigevent *sevp) value inside the function. Same inside dce_timer_settime() call , it register a event handler and when the time expire call it will get call and re register itself and doing nothing other than this. Below code present inside DCE 1.8 and 1.9.  

void
UnixTimerFd::TimerExpired (void)
{
  if (!m_period.IsZero ())-----------Time to expire
    {
      m_timer = Simulator::Schedule (m_period,
                                     &UnixTimerFd::TimerExpired,
                                     this);
    }
  m_skipped++;
  if (m_waiter != 0)
    {
      m_waiter->process->manager->Wakeup (m_waiter);
    }
}

When i run the DCE script the timer handler(timerHandler) not getting invoked after waiting of long duration.
             
Please provide me a solution if anybody has any solution for it.

Thanks,
Jay  
             
sm-v.c
Sbsn.cc

Jayasantosh Samal

unread,
Apr 12, 2017, 8:38:30 AM4/12/17
to ns-3-users, Randy....@landisgyr.com, Ruben....@landisgyr.com, vishal...@landisgyr.com
I have gone through the DCE source code and find out signal is not passing to process when the timer expire. So i have modified and added few lines of code into the file attached into this mail. Now am able to get signal from signal handler. I have also tested it by using multiple application. Please review and suggest, is the changes looks good for DCE. You can find my added and changes code under a comments "Added by jay". 

Thanks,
Jay  
unix-timer-fd.cc
unix-timer-fd.h
dce-time.cc

Matt Anonyme

unread,
Apr 16, 2017, 6:54:21 PM4/16/17
to ns-3-users, Randy....@landisgyr.com, Ruben....@landisgyr.com, vishal...@landisgyr.com
Thanks for the patch.

It would be nice if you could submit it a pull request here https://github.com/direct-code-execution/ns-3-dce to run the testsuite else I can try to commit it myself with git --author <you>.

Jayasantosh Samal

unread,
Apr 19, 2017, 8:22:26 AM4/19/17
to ns-3-users, Randy....@landisgyr.com, Ruben....@landisgyr.com, vishal...@landisgyr.com
Please find attached result.txt , run on Patch.

Thanks,
Jay
results.txt
Reply all
Reply to author
Forward
0 new messages