ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/timer.cpp
(Generate patch)

Comparing SheepShaver/src/timer.cpp (file contents):
Revision 1.6 by gbeauche, 2005-03-16T00:35:51Z vs.
Revision 1.10 by asvitkine, 2009-07-31T20:43:28Z

# Line 1 | Line 1
1   /*
2   *  timer.cpp - Time Manager emulation
3   *
4 < *  SheepShaver (C) 1997-2005 Christian Bauer and Marc Hellwig
4 > *  SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 18
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  
21 /*
22 * TODO: Prime(0)
23 */
24
21   #include "sysdeps.h"
22   #include "timer.h"
23   #include "macos_util.h"
# Line 428 | Line 424 | int16 PrimeTime(uint32 tm, int32 time)
424                  // Yes, tmWakeUp set?
425                  if (ReadMacInt32(tm + tmWakeUp)) {
426  
427 <                        //!! PrimeTime(0) means continue previous delay
428 <                        // (save wakeup time in RmvTime?)
429 <                        if (time == 0) {
430 <                                printf("FATAL: Unsupported PrimeTime(0)\n");
431 <                                return 0;
436 <                        }
427 >                        // PrimeTime(0) can either mean (a) "the task runs as soon as interrupts are enabled"
428 >                        // or (b) "continue previous delay" if an expired task was stopped via RmvTime() and
429 >                        // then re-installed using InsXTime(). Since tmWakeUp was set, this is case (b).
430 >                        // The remaining time was saved in tmCount by RmvTime().
431 >                        timer_mac2host_time(delay, ReadMacInt16(tm + tmCount));
432  
433                          // Yes, calculate wakeup time relative to last scheduled time
434                          tm_time_t wakeup;
# Line 532 | Line 527 | static void *timer_func(void *arg)
527  
528                  tm_time_t system_time;
529                  timer_current_time(system_time);
535                pthread_mutex_lock(&wakeup_time_lock);
530                  if (timer_cmp_time(wakeup_time, system_time) < 0) {
531  
532                          // Timer expired, trigger interrupt
533 +                        pthread_mutex_lock(&wakeup_time_lock);
534                          wakeup_time = wakeup_time_max;
535 +                        pthread_mutex_unlock(&wakeup_time_lock);
536                          SetInterruptFlag(INTFLAG_TIMER);
537                          TriggerInterrupt();
538                  }
543                pthread_mutex_unlock(&wakeup_time_lock);
539          }
540          return NULL;
541   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines