ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/timer_unix.cpp
Revision 1.22 - (view) (annotate) - [select for diffs]
2009-08-21T17:39:58Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
CVS Tags: HEAD
Changes since 1.21: +1 -1 lines
Diff to previous 1.21
Change #include <mach/mach_host.h> to #include <mach/mach.h>

Revision 1.21 - (view) (annotate) - [select for diffs]
2009-08-17T20:42:26Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
Changes since 1.20: +33 -6 lines
Diff to previous 1.20
[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.20 - (view) (annotate) - [select for diffs]
2008-01-01T09:40:33Z (16 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.19: +1 -1 lines
Diff to previous 1.19
Happy New Year!

Revision 1.19 - (view) (annotate) - [select for diffs]
2006-05-01T13:13:18Z (18 years, 6 months ago) by gbeauche
Branch: MAIN
CVS Tags: nigel-build-19
Changes since 1.18: +6 -2 lines
Diff to previous 1.18
improve locks

Revision 1.18 - (view) (annotate) - [select for diffs]
2005-06-30T10:34:31Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
CVS Tags: nigel-build-17
Changes since 1.17: +2 -0 lines
Diff to previous 1.17
POSIX conforming use of pthread_cond_wait().

Revision 1.17 - (view) (annotate) - [select for diffs]
2005-06-30T10:20:18Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.16: +69 -0 lines
Diff to previous 1.16
Add system-specific implementations of idle_{wait,resume} functions.

Revision 1.16 - (view) (annotate) - [select for diffs]
2005-02-21T22:57:03Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.15: +1 -1 lines
Diff to previous 1.15
nanosleep() delays seem better suited to MacOS X, instead of select()

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

Revision 1.14 - (view) (annotate) - [select for diffs]
2004-01-12T15:29:25Z (20 years, 10 months ago) by cebix
Branch: MAIN
CVS Tags: nigel-build-15, nigel-build-16
Changes since 1.13: +1 -1 lines
Diff to previous 1.13
Happy New Year! :)

Revision 1.13 - (view) (annotate) - [select for diffs]
2002-01-15T14:58:37Z (22 years, 10 months ago) by cebix
Branch: MAIN
CVS Tags: nigel-build-12, nigel-build-13, snapshot-15012002
Changes since 1.12: +1 -1 lines
Diff to previous 1.12
- documentation updates
- 2001 -> 2002
- version 0.9 -> 1.0

Revision 1.12 - (view) (annotate) - [select for diffs]
2001-07-09T15:44:58Z (23 years, 4 months ago) by cebix
Branch: MAIN
Changes since 1.11: +1 -0 lines
Diff to previous 1.11
Irix needs pthread cond variables which need the pthread.h header file

Revision 1.11 - (view) (annotate) - [select for diffs]
2001-07-09T11:22:00Z (23 years, 4 months ago) by cebix
Branch: MAIN
Changes since 1.10: +100 -0 lines
Diff to previous 1.10
- ADB has its own interrupt flag, INTFLAG_ADB
- ADBMouseMoved(), ADBMouseDown/Up() and ADBKeyDown/Up() trigger the ADB
  interrupt
- ADB mutex is only used for mouse movement (the only input state where it
  matters)
- adb.cpp: toggling relative mouse mode resets mouse_x/y
- PrimeTime(0) schedules a timer task with 0 delay time; this is still not
  the correct implementation, but it makes MacSyndicate work...
- Unix: pthreads are preferred to POSIX.4 timers for 60Hz ticks because the
  timers drift badly under Linux and the thread can compensate for drifting
  well enough
- Unix: moved GetTicks_usec() and Delay_usec() to timer_unix.cpp
- video_x.cpp: X mouse acceleration is disabled in relative mouse mode because
  MacOS does its own acceleration
- video_x.cpp: palette[].pixel and palette[].flags are always preset
- video_x.cpp: decoupled X event handling from 60Hz video refresh cycle by
  using select() with a timeout on the X fd

Revision 1.10 - (view) (annotate) - [select for diffs]
2001-07-06T17:36:08Z (23 years, 4 months ago) by cebix
Branch: MAIN
Changes since 1.9: +2 -9 lines
Diff to previous 1.9
replaced TIME_OFFSET constant by portable TimeToMacTime() function

Revision 1.9 - (view) (annotate) - [select for diffs]
2001-02-02T20:52:58Z (23 years, 9 months ago) by cebix
Branch: MAIN
CVS Tags: release-0_9-1, snapshot-17022001, snapshot-29052001
Changes since 1.8: +1 -1 lines
Diff to previous 1.8
- bumped version number to 0.9
- updated copyright dates

Revision 1.8 - (view) (annotate) - [select for diffs]
2000-07-13T13:47:12Z (24 years, 4 months ago) by cebix
Branch: MAIN
CVS Tags: snapshot-13072000
Changes since 1.7: +5 -0 lines
Diff to previous 1.7
- first version to run natively on NetBSD/m68k

Revision 1.7 - (view) (annotate) - [select for diffs]
2000-04-10T18:53:08Z (24 years, 7 months ago) by cebix
Branch: MAIN
Changes since 1.6: +1 -1 lines
Diff to previous 1.6
- updated copyright info: 1999->2000

Revision 1.6 - (view) (annotate) - [select for diffs]
2000-02-21T20:04:18Z (24 years, 9 months ago) by cebix
Branch: MAIN
Changes since 1.5: +1 -4 lines
Diff to previous 1.5
- Unix: changed time zone handling (again)

Revision 1.5 - (view) (annotate) - [select for diffs]
1999-10-19T17:41:39Z (25 years, 1 month ago) by cebix
Branch: MAIN
CVS Tags: release-0_8-1, snapshot-02111999, snapshot-21101999, snapshot-22121999
Changes since 1.4: +0 -2 lines
Diff to previous 1.4
- added external file system
- moved most init/deinit code to InitAll()/ExitAll() in main.cpp

Revision 1.4 - (view) (annotate) - [select for diffs]
1999-10-15T15:06:55Z (25 years, 1 month ago) by cebix
Branch: MAIN
Changes since 1.3: +1 -1 lines
Diff to previous 1.3
- fixed small compilation problem

Revision 1.3 - (view) (annotate) - [select for diffs]
1999-10-15T14:50:39Z (25 years, 1 month ago) by cebix
Branch: MAIN
Changes since 1.2: +7 -1 lines
Diff to previous 1.2
- some fixes for NetBSD

Revision 1.2 - (view) (annotate) - [select for diffs]
1999-10-14T16:05:18Z (25 years, 1 month ago) by cebix
Branch: MAIN
Changes since 1.1: +5 -4 lines
Diff to previous 1.1
- corrected time zone handling in TimerDateTime()

Revision 1.1 - (view) (annotate) - [select for diffs]
1999-10-03T14:16:25Z (25 years, 1 month ago) by cebix
Branch: MAIN
Branch point for: cebix
Initial revision

Convenience Links

Links to HEAD: (view) (annotate) 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