u64_t tsc, tsc_delta;
u64_t * __tsc_ctr_switch = get_cpulocal_var_ptr(tsc_ctr_switch);
- read_tsc_64(&tsc);
- tsc_delta = sub64(tsc, *__tsc_ctr_switch);
- p->p_cycles = add64(p->p_cycles, tsc_delta);
-
- /*
- * deduct the just consumed cpu cycles from the cpu time left for this
- * process during its current quantum. Skip IDLE and other pseudo kernel
- * tasks
- */
- if (p->p_endpoint >= 0) {
-#if DEBUG_RACE
- make_zero64(p->p_cpu_time_left);
-#else
- /* if (tsc_delta < p->p_cpu_time_left) in 64bit */
- if (tsc_delta.hi < p->p_cpu_time_left.hi ||
- (tsc_delta.hi == p->p_cpu_time_left.hi &&
- tsc_delta.lo < p->p_cpu_time_left.lo))
- p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta);
- else {
- make_zero64(p->p_cpu_time_left);
- }
-#endif
- }
-
+#ifdef CONFIG_SMP
/*
* This function is called only if we switch from kernel to user or idle
* or back. Therefore this is a perfect location to place the big kernel
kernel_ticks[cpu] = add64(kernel_ticks[cpu], tmp);
p->p_cycles = add64(p->p_cycles, tmp);
}
+#else
+ read_tsc_64(&tsc);
+ p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch));
+#endif
+ tsc_delta = sub64(tsc, *__tsc_ctr_switch);
+
+ /*
+ * deduct the just consumed cpu cycles from the cpu time left for this
+ * process during its current quantum. Skip IDLE and other pseudo kernel
+ * tasks
+ */
+ if (p->p_endpoint >= 0) {
+#if DEBUG_RACE
+ make_zero64(p->p_cpu_time_left);
+#else
+ /* if (tsc_delta < p->p_cpu_time_left) in 64bit */
+ if (tsc_delta.hi < p->p_cpu_time_left.hi ||
+ (tsc_delta.hi == p->p_cpu_time_left.hi &&
+ tsc_delta.lo < p->p_cpu_time_left.lo))
+ p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta);
+ else {
+ make_zero64(p->p_cpu_time_left);
+ }
+#endif
+ }
+
*__tsc_ctr_switch = tsc;
}
* kernel.
*/
-
/*
* The routines only guarantee to preserve the registers the C compiler
* expects to be preserved (ebx, esi, edi, ebp, esp, segment registers, and
switch_address_space_idle();
+#ifdef CONFIG_SMP
/* we don't need to keep time on APs as it is handled on the BSP */
if (cpuid != bsp_cpu_id)
arch_stop_local_timer();
get_cpulocal_var(cpu_is_idle) = 1;
+#endif
/* start accounting for the idle time */
context_stop(proc_addr(KERNEL));
if (quantum < 1 && quantum != -1)
return(EINVAL);
+#ifdef CONFIG_SMP
if ((cpu < 0 && cpu != -1) || (cpu > 0 && (unsigned) cpu >= ncpus))
return(EINVAL);
+#endif
/* In some cases, we might be rescheduling a runnable process. In such
* a case (i.e. if we are updating the priority) we set the NO_QUANTUM
/* FIXME this is a problem for SMP if the processes currently runs on a
* different CPU */
if (proc_is_runnable(p)) {
+#ifdef CONFIG_SMP
if (p->p_cpu != cpuid && cpu != -1 && cpu != p->p_cpu) {
printf("WARNING : changing cpu of a runnable process %d "
"on a different cpu!\n", p->p_endpoint);
return(EINVAL);
}
+#endif
RTS_SET(p, RTS_NO_QUANTUM);
}
p->p_quantum_size_ms = quantum;
p->p_cpu_time_left = ms_2_cpu_time(quantum);
}
+#ifdef CONFIG_SMP
if (cpu != -1)
p->p_cpu = cpu;
+#endif
/* Clear the scheduling bit and enqueue the process */
RTS_UNSET(p, RTS_NO_QUANTUM);
EXTERN char monitor_code[256];
EXTERN struct machine machine; /* machine info */
+#ifdef CONFIG_SMP
EXTERN unsigned cpu_proc[CONFIG_MAX_CPUS];
+#endif
#define EXTERN
#endif
+#ifndef CONFIG_SMP
+#define CONFIG_MAX_CPUS 1
+#endif
+
/**
* We might later want to add more information to this table, such as the
* process owner, process group or cpumask.
}
rmp = &schedproc[proc_nr_n];
+#ifdef CONFIG_SMP
cpu_proc[rmp->cpu]--;
+#endif
rmp->flags = 0; /*&= ~IN_USE;*/
return OK;
* changed that yet either, we can be sure that BSP is the
* processor where the processes run now.
*/
+#ifdef CONFIG_SMP
rmp->cpu = machine.bsp_id;
/* FIXME set the cpu mask */
+#endif
}
switch (m_ptr->m_type) {