[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BOUNCE rtl@rtlinux.org: Approval required: (fwd)



>From owner-rtl Fri May 11 12:53:02 2001
Received: from hq.fsmlabs.com (localhost [[UNIX: localhost]])
	by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4BIqag07009
	for <rtl@fsmlabs.com>; Fri, 11 May 2001 12:52:42 -0600
Received: (qmail 914 invoked by uid 1000); 11 May 2001 17:18:54 -0000
Date: Fri, 11 May 2001 21:18:54 +0400
From: Michael Barabanov <baraban@fsmlabs.com>
To: karl rentsch <krentsch@btr-auto.aust.com>
Cc: rtl@fsmlabs.com
Subject: Re: [rtl] putting threads to sleep
Message-ID: <20010511211854.A894@huevo.fsmlabs.com>
References: <A3A5582AC3AFD448A7C0BD2DB7EFDC5F1143B1@BTR-COM1.btr-auto.aust.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.3.17i
In-Reply-To: <A3A5582AC3AFD448A7C0BD2DB7EFDC5F1143B1@BTR-COM1.btr-auto.aust.com>; from krentsch@btr-auto.aust.com on Thu, May 10, 2001 at 08:39:44AM +1000
Organization: FSMLabs

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 (krentsch@btr-auto.aust.com) 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 majordomo@rtlinux.org OR
> echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.org
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/