Quantcast

Maximum PC

It is currently Sat Jul 12, 2014 1:52 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to write a sleep or delay function?
PostPosted: Sun Oct 24, 2004 4:19 pm 
8086
8086

Joined: Mon Aug 02, 2004 10:59 am
Posts: 50
I don't really know how to do it. I can't use SYSCALLS or the like. I think I would have to use a useless loop like
Code:
void wait(int x)
{ int timeout = x;
  while (timeout >= 0)
    timeout--;
  return;
}


The main problem with this is it wouldn't be correct for every processor or even on the same processor depending on the priority of the process. I'd have to write a calibration function but I don't want that to take up too much time as well. Any help would be appreciated, especially code, but conceptual help is great too. Thanks all.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 4:42 pm 
In the lab!
In the lab!
User avatar

Joined: Sun Jun 06, 2004 10:47 am
Posts: 831
Location: Secret Laboratory
you should really use a system call/api but if you can't you have to use a timer/clock based values to guarantee consistant time results regardless of system speed/os/etc.

I'd suggest you take a look at "time.h" and the functions it provides.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 8:38 pm 
8086
8086

Joined: Mon Aug 02, 2004 10:59 am
Posts: 50
I can access interrupts, though not the API...could I code an ISR for IRQ0 (the system timer) and use that? How would I save the previous vector if something else is using it? Is there a way to modify the rate at which IRQ0 fires? Thanks again.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 2:59 am 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Kybo_Ren posted this in a different thread here. I think it will help you out quite a bit.

http://www.math.uwaterloo.ca/~jamuir/rdtscpm1.pdf


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group