diff options
Diffstat (limited to 'kern')
-rw-r--r-- | kern/mach_clock.c | 26 | ||||
-rw-r--r-- | kern/task.c | 5 |
2 files changed, 23 insertions, 8 deletions
diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 48f673a4..d7858a79 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -90,6 +90,9 @@ unsigned bigadj = 1000000; /* adjust 10*tickadj if adjustment * and the difference between these two read is multiplied by the counter * period and added to the read value from time or uptime to get a more * accurate time read. */ +#if NCPUS > 1 +#warning This needs fixing +#endif uint32_t last_hpc_read = 0; /* @@ -132,24 +135,30 @@ MACRO_END #define read_mapped_time(time) \ MACRO_BEGIN \ + uint32_t _last_hpc; \ do { \ + _last_hpc = last_hpc_read; \ (time)->seconds = mtime->time_value.seconds; \ __sync_synchronize(); \ (time)->nanoseconds = mtime->time_value.nanoseconds; \ __sync_synchronize(); \ - } while ((time)->seconds != mtime->check_seconds64); \ - time_value64_add_hpc(time); \ + } while (((time)->seconds != mtime->check_seconds64) \ + || (_last_hpc != last_hpc_read)); \ + time_value64_add_hpc(time, _last_hpc); \ MACRO_END -#define read_mapped_uptime(uptime) \ +#define read_mapped_uptime(uptime) \ MACRO_BEGIN \ + uint32_t _last_hpc; \ do { \ + _last_hpc = last_hpc_read; \ (uptime)->seconds = mtime->uptime_value.seconds; \ __sync_synchronize(); \ (uptime)->nanoseconds = mtime->uptime_value.nanoseconds;\ __sync_synchronize(); \ - } while ((uptime)->seconds != mtime->check_upseconds64); \ - time_value64_add_hpc(uptime); \ + } while (((uptime)->seconds != mtime->check_upseconds64) \ + || (_last_hpc != last_hpc_read)); \ + time_value64_add_hpc(uptime, _last_hpc); \ MACRO_END def_simple_lock_irq_data(static, timer_lock) /* lock for ... */ @@ -373,7 +382,8 @@ void set_timeout( s = simple_lock_irq(&timer_lock); - interval += elapsed_ticks; + /* Start counting after next tick, to avoid partial ticks. */ + interval += elapsed_ticks + 1; for (next = (timer_elt_t)queue_first(&timer_head.chain); ; @@ -442,11 +452,11 @@ clock_boottime_update(const struct time_value64 *new_time) * Add the time value since last clock interrupt in nanosecond. */ static void -time_value64_add_hpc(time_value64_t *value) +time_value64_add_hpc(time_value64_t *value, uint32_t last_hpc) { uint32_t now = hpclock_read_counter(); /* Time since last clock interrupt in nanosecond. */ - int64_t ns = (now - last_hpc_read) * hpclock_get_counter_period_nsec(); + int64_t ns = (now - last_hpc) * hpclock_get_counter_period_nsec(); /* Limit the value of ns under the period of a clock interrupt. */ if (ns >= tick * 1000) diff --git a/kern/task.c b/kern/task.c index bd57ca2a..e78e856f 100644 --- a/kern/task.c +++ b/kern/task.c @@ -126,6 +126,11 @@ task_create_kernel( trunc_page(VM_MAX_USER_ADDRESS)); if (new_task->map == VM_MAP_NULL) pmap_destroy(new_pmap); + else if (parent_task != TASK_NULL) { + vm_map_lock_read(parent_task->map); + vm_map_copy_limits(new_task->map, parent_task->map); + vm_map_unlock_read(parent_task->map); + } } } if (new_task->map == VM_MAP_NULL) { |