Skip to contentSkip to conversation

nanosleep returns -1 unless using SCHED_FIFO.

Xenomai Henry Bausley 2 participants 3 messages Aug 23, 2012

lore
Share & tools
lore
#0 lore raw

With xenomai 2.5.6 nanosleep no longer works unless the application is using SCHED_FIFO. Previously we used xenomai 2.4.10 and the code would nanosleep.

int main(void)
{
struct timespec SecSleeper = {0};
SecSleeper.tv_sec = 1;
SecSleeper.tv_nsec = 0;
int P[3];

// param.__sched_priority = 1;
// pthread_setschedparam(pthread_self(), SCHED_FIFO, &param); while (1)

  {
        printf("Dummy\n");
        P[1]++;
        P[2] = nanosleep(&SecSleeper, NULL);
        P[3] = errno;

}
return 0;
}

Is this behavior expected?

Outbound scan for Spam or Virus by Barracuda at Delta Tau

#1 lore raw
Quoted 14 lines · Henry Bausley

With xenomai 2.5.6 nanosleep no longer works unless the application is using SCHED_FIFO. Previously we used xenomai 2.4.10 and the code would nanosleep.

int main(void)
{
struct timespec SecSleeper = {0};
SecSleeper.tv_sec = 1;
SecSleeper.tv_nsec = 0;
int P[3];

Quoted 8 lines
  // param.__sched_priority = 1;
  // pthread_setschedparam(pthread_self(),  SCHED_FIFO, &param);    
  while (1)
  {
        printf("Dummy\n");
        P[1]++;
        P[2] = nanosleep(&SecSleeper, NULL);
        P[3] = errno;

^ out of bounds

Quoted 6 lines

}
return 0;
}

Is this behavior expected?

nanosleep is reserved to xenomai threads. But normally the main thread is a xenomai thread, unless you configured xenomai user-space with --enable-dlopen-skins, so, should be allowed to nanosleep. Apart from the missing call to mlockall (unless you configured xenomai user-space with --enable-posix-auto-mlockall), your test case runs fine with xenomai 2.6.1.

Signature · 1 line
                                                                Gilles.
#2 lore raw

Thanks.

I did compile with --enable-dlopen-skins and --enable-posix-auto-mlockall. Without --enable-dlopen-skins everything is fine

Quoted 35 lines · Gilles Chanteperdrix
Quoted 14 lines · Henry Bausley

With xenomai 2.5.6 nanosleep no longer works unless the application is using SCHED_FIFO. Previously we used xenomai 2.4.10 and the code would nanosleep.

int main(void)
{
struct timespec SecSleeper = {0};
SecSleeper.tv_sec = 1;
SecSleeper.tv_nsec = 0;
int P[3];

Quoted 8 lines
  // param.__sched_priority = 1;
  // pthread_setschedparam(pthread_self(),  SCHED_FIFO, &param);    
  while (1)
  {
        printf("Dummy\n");
        P[1]++;
        P[2] = nanosleep(&SecSleeper, NULL);
        P[3] = errno;

^ out of bounds

Quoted 6 lines

}
return 0;
}

Is this behavior expected?

Quoted 7 lines

nanosleep is reserved to xenomai threads. But normally the main thread is a xenomai thread, unless you configured xenomai user-space with --enable-dlopen-skins, so, should be allowed to nanosleep. Apart from the missing call to mlockall (unless you configured xenomai user-space with --enable-posix-auto-mlockall), your test case runs fine with xenomai 2.6.1.

Outbound scan for Spam or Virus by Barracuda at Delta Tau