don't deref desc after deleting it!
add NULL return value to macho timer function
use linked list for timers to avoid running out of descriptors
[Charles Srstka] Attached is a set of patches to port the precise timer that is currently used in the Linux and BeOS builds of SheepShaver to Mac OS X (and any other Mach-based operating systems). Currently, the Linux build uses the clock_gettime() function to get nanosecond-precision time, and falls back on gettimeofday() if it is not present. Unfortunately, Mac OS X does not currently support clock_gettime(), and gettimeofday() has only microsecond granularity. The Mach kernel, however, has a clock_get_time() function that does very nearly the same thing as clock_gettime(). The patches to BasiliskII cause the timing functions such as timer_current_time() to use clock_get_time() instead of gettimeofday() on Mach-based systems that do not support clock_gettime(). The changes to SheepShaver involve the precise timer. The existing code for Linux uses pthreads and real-time signals to handle the timing. Mac OS X unfortunately does not seem to support real-time signals, so Mach calls are again used to suspend and resume the timer thread in order to attempt to duplicate the Linux and BeOS versions of the timer. The code is somewhat ugly right now, as I decided to leave alone the pre-existing style of the source file, which unfortunately involves #ifdefs scattered throughout the file and some duplication of code. A future patch may want to clean this up to separate out the OS-specific code and put it all together at the top of the file. However, for the time being, this seems to work. This has not been extensively tested, because I have not been able to get my hands on a good test-case app for the classic Mac OS that would run inside the emulator and try out the timer. However, performance does seem to be better than with the pre-existing code, and nothing seems to have blown up as far as I can tell. I did find a game via a Google search - Cap'n Magneto - that is known to have problems with Basilisk/SheepShaver's legacy 60 Hz timer, and the opening fade-to-color for this game appears to run much more smoothly with the precise timer code in place.
only "continue previous delay" if delay is 0
correct implementation of PrimeTime(0)
handle one case of PrimeTime(0)
Happy New Year!
Hopefully fix the remaining issue in the High Resolution Timing support code and re-enable it on Linux platforms (they have clock_nanosleep). Why did I trigger an interrupt inside a held lock? Hmmm, we should probably add an _ack semaphore like we do e.g. for ethernet.
Use a mutex to protect wakeup_time instead of a semaphore, do we want some sort of barrier synchronisation? Anyhow, the current implementation looks reasonable enough now when using old LinuxThreads without TLS. XXX: in the past, the sem_post in sigsuspend_handler would not release the calling thread thus entering into a mutual waiting condition.
fix initialization of timer thread that could be put in indefinite suspended state from the start.
Enable high precision timings on POSIX systems supporting clock_nanosleep(). Since pthread_suspend_np() is not available to Linux (but NetBSD 2.0), thread suspend is implemented likewise to boehm-gc.
Happy New Year 2005!
Happy New Year! :)
Imported sources
Initial revision
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, select a symbolic revision name using the selection box, or choose 'Use Text Field' and enter a numeric revision.