Actually, the system does not spin when you call usleep, clock_nanosleep
or nanosleep functions from an rt-thread. The thread is blocked just like with
pthread_wait_np.  In fact, use of these functions is preferred to
pthread_wait_np since they are standard in POSIX.

Michael.

karl rentsch ([EMAIL PROTECTED]) wrote:
> 
> Thanks everyone, but I've got it sorted out now.  I upgraded from the
> development RT-Linux (3.0 pre ?) to the latest 3.0 kernal and it seems
> to have solved the problem of the one-shot pthread_make_periodic
> function not resetting (I can't remeber changing anything else).  Here's
> the code for interest:
> 
> void *can_update(void *pparams)
> {
>       volatile sched_can_msg_t *msg;
>       can_output_t can_output_data;
>       hrtime_t time, sched_time;
>       int i = 0;
> 
>       while(1) {
>               msg = can_objects->can_messages;
>               time = gethrtime();
>               sched_time = time + 10000000LL;
>               
>               for(i = 0; i < can_objects->no_entries; i++) {
>                       if(msg->id >= 0) {
>                               if(time > (msg->last_sent +
> msg->period)) {
>                               can_output_data.msg.port = msg->channel;
>                               can_output_data.msg.id = msg->id;
>                               can_output_data.msg.datalen =
> msg->datalen;
>       
> memcpy(&can_output_data.msg.data, &msg->data,
> sizeof(can_output_data.msg.data));
>                                       rtf_put(CAN_DRV_TX_FIFO,
> &can_output_data, sizeof(can_output_t));
>                                       msg->last_sent = gethrtime();
> 
>                               }
>                               if(sched_time > (msg->last_sent +
> msg->period)) {
>                                       sched_time = msg->last_sent +
> msg->period;
>                               }
>                       }
>                       msg++;
>               }
>               pthread_make_periodic_np(pthread_self(), sched_time, 0);
>               pthread_wait_np();
>       }
>       return 0;
> }
> 
> Regards
> 
> Karl Rentsch
> 
> 
> > karl rentsch wrote:
> > 
> > Hi all,
> >
> > I've got a problem I hope someone can help me with.  I'm trying to put
> a
> > thread to sleep but I don't want to tie up the system using usleep()
> or
> > nanosleep().  I've tried using pthread_make_periodic_np configured as
> a
> > one shot timer (ie. it needs to repeat several times but for different
> > time intervals) but it doesn't seem to work
> > Any help would be much appreciated
> > Thanks
> > Karl Rentsch
> 
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to