Commit Graph

18 Commits

Author SHA1 Message Date
asvitkine
2ea84d86c7 Fix some compile warnings with Xcode project build. 2022-04-04 13:53:53 -04:00
kanjitalk755
6c20f2c4d9 fix for deadlock in timer 2020-11-07 11:52:24 +09:00
Alexei Svitkine
d3cb3ca95f Fix some warnings when building Xcode project. 2015-06-29 11:50:50 -04:00
asvitkine
eebe0b0c13 don't deref desc after deleting it! 2011-12-28 18:14:58 +00:00
asvitkine
14339fb01f add NULL return value to macho timer function 2010-08-22 19:31:36 +00:00
asvitkine
efad3ba70a use linked list for timers to avoid running out of descriptors 2010-05-05 00:29:46 +00:00
asvitkine
5a8dfa1b36 [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.
2009-08-17 20:44:30 +00:00
asvitkine
5cef748ac7 only "continue previous delay" if delay is 0 2009-08-01 07:02:41 +00:00
asvitkine
ccdb8ab3c0 correct implementation of PrimeTime(0) 2009-07-31 20:43:28 +00:00
asvitkine
57b64245ad handle one case of PrimeTime(0) 2009-07-31 19:41:50 +00:00
gbeauche
054c37ca0c Happy New Year! 2008-01-01 09:47:39 +00:00
gbeauche
2881c20813 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.
2005-07-01 23:15:11 +00:00
gbeauche
dd7b09ebe8 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.
2005-03-16 00:35:51 +00:00
gbeauche
260614a873 fix initialization of timer thread that could be put in indefinite suspended
state from the start.
2005-03-15 20:46:50 +00:00
gbeauche
e7d8a54e21 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.
2005-03-05 19:07:35 +00:00
gbeauche
df0d5d2a41 Happy New Year 2005! 2005-01-30 21:48:22 +00:00
cebix
2d5de1af9d Happy New Year! :) 2004-01-12 15:37:24 +00:00
cebix
8e4d5e5f40 Imported sources 2002-02-04 16:58:13 +00:00