ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/timer.cpp
Revision 1.15 - (view) (annotate) - [select for diffs]
2011-12-28T18:14:58Z (12 years, 11 months ago) by asvitkine
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +1 -1 lines
Diff to previous 1.14
don't deref desc after deleting it!

Revision 1.14 - (view) (annotate) - [select for diffs]
2010-08-22T19:31:36Z (14 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.13: +1 -0 lines
Diff to previous 1.13
add NULL return value to macho timer function

Revision 1.13 - (view) (annotate) - [select for diffs]
2010-05-05T00:29:46Z (14 years, 6 months ago) by asvitkine
Branch: MAIN
Changes since 1.12: +80 -87 lines
Diff to previous 1.12
use linked list for timers to avoid running out of descriptors

Revision 1.12 - (view) (annotate) - [select for diffs]
2009-08-17T20:44:30Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.11: +74 -1 lines
Diff to previous 1.11
[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.

Revision 1.11 - (view) (annotate) - [select for diffs]
2009-08-01T07:02:41Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.10: +3 -1 lines
Diff to previous 1.10
only "continue previous delay" if delay is 0

Revision 1.10 - (view) (annotate) - [select for diffs]
2009-07-31T20:43:28Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.9: +3 -16 lines
Diff to previous 1.9
correct implementation of PrimeTime(0)

Revision 1.9 - (view) (annotate) - [select for diffs]
2009-07-31T19:41:50Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.8: +8 -0 lines
Diff to previous 1.8
handle one case of PrimeTime(0)

Revision 1.8 - (view) (annotate) - [select for diffs]
2008-01-01T09:47:38Z (16 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.7: +1 -1 lines
Diff to previous 1.7
Happy New Year!

Revision 1.7 - (view) (annotate) - [select for diffs]
2005-07-01T23:15:11Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.6: +2 -2 lines
Diff to previous 1.6
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.

Revision 1.6 - (view) (annotate) - [select for diffs]
2005-03-16T00:35:51Z (19 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.5: +12 -13 lines
Diff to previous 1.5
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.

Revision 1.5 - (view) (annotate) - [select for diffs]
2005-03-15T20:46:50Z (19 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.4: +13 -9 lines
Diff to previous 1.4
fix initialization of timer thread that could be put in indefinite suspended
state from the start.

Revision 1.4 - (view) (annotate) - [select for diffs]
2005-03-05T19:07:35Z (19 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.3: +195 -17 lines
Diff to previous 1.3
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.

Revision 1.3 - (view) (annotate) - [select for diffs]
2005-01-30T21:48:19Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.2: +1 -1 lines
Diff to previous 1.2
Happy New Year 2005!

Revision 1.2 - (view) (annotate) - [select for diffs]
2004-01-12T15:37:19Z (20 years, 10 months ago) by cebix
Branch: MAIN
Changes since 1.1: +1 -1 lines
Diff to previous 1.1
Happy New Year! :)

Revision 1.1.1.1 - (view) (annotate) - [select for diffs] (vendor branch)
2002-02-04T16:58:13Z (22 years, 9 months ago) by cebix
Branch: cebix
CVS Tags: start
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 , to next main 1.15
Imported sources

Revision 1.1 - (view) (annotate) - [select for diffs]
2002-02-04T16:58:13Z (22 years, 9 months ago) by cebix
Branch: MAIN
Branch point for: cebix
Initial revision

Convenience Links

Links to HEAD: (view) (annotate)

Compare Revisions

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.

  Diffs between and
  Type of Diff should be a