Rev 131 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 131 | Rev 139 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | <chapter id="time"> |
2 | <chapter id="time"> |
3 | <?dbhtml filename="time.html"?> |
3 | <?dbhtml filename="time.html"?> |
4 | 4 | ||
5 | <title>Time Management</title> |
5 | <title>Time Management</title> |
6 | 6 | ||
7 | <para>Time is one of the dimensions in which kernel, as well as the whole |
7 | <para>Time is one of the dimensions in which kernel as well as the whole |
8 | system, operates. It is of special importance to many kernel subsytems. |
8 | system operates. It is of special importance to many kernel subsytems. |
9 | Knowledge of time makes it possible for the scheduler to preemptively plan |
9 | Knowledge of time makes it possible for the scheduler to preemptively plan |
10 | threads for execution. Different parts of the kernel can request execution |
10 | threads for execution. Different parts of the kernel can request execution |
11 | of their callback function with some specified delay. A good example of such |
11 | of their callback function with a specified delay. A good example of such |
12 | kernel code is the synchronization subsystem which uses this functionality |
12 | kernel code is the synchronization subsystem which uses this functionality |
13 | to implement timeouting versions of synchronization primitives.</para> |
13 | to implement timeouting versions of synchronization primitives.</para> |
14 | 14 | ||
15 | <section> |
15 | <section> |
16 | <title>System Clock</title> |
16 | <title>System Clock</title> |
Line 48... | Line 48... | ||
48 | <para>The kernel must reinitialize one of the two registers after each |
48 | <para>The kernel must reinitialize one of the two registers after each |
49 | clock interrupt in order to schedule next interrupt. However this step is |
49 | clock interrupt in order to schedule next interrupt. However this step is |
50 | tricky and must be done with caution. Imagine that the clock interrupt is |
50 | tricky and must be done with caution. Imagine that the clock interrupt is |
51 | masked either because the kernel is servicing another interrupt or because |
51 | masked either because the kernel is servicing another interrupt or because |
52 | the processor locally disabled interrupts for a while. If the clock |
52 | the processor locally disabled interrupts for a while. If the clock |
53 | interrupt occurs during this period, it will be pending until interrupts |
53 | interrupt occurs during this period, it will be pending until the |
54 | are enabled again. In theory, that could happen arbitrary counter register |
54 | interrupts are enabled again. Theoretically, it could happen an arbitrary |
55 | ticks later. Which is worse, the ideal time period between two non-delayed |
55 | counter register ticks later. Which is worse, the ideal time period |
56 | clock interrupts can also elapse arbitrary number of times before the |
56 | between two non-delayed clock interrupts can also elapse arbitrary number |
57 | delayed interrupt gets serviced. The architecture-specific part of the |
57 | of times before the delayed interrupt gets serviced. The |
58 | clock interrupt driver must avoid time drifts caused by this by taking |
58 | architecture-specific part of the clock interrupt driver must avoid time |
- | 59 | drifts caused by such behaviour by taking proactive |
|
59 | proactive counter-measures.</para> |
60 | counter-measures.</para> |
60 | 61 | ||
61 | <para>Let us assume that the kernel wants each clock interrupt be |
62 | <para>Let us assume that the kernel wants each clock interrupt be |
62 | generated every <constant>TICKCONST</constant> ticks. This value |
63 | generated every <constant>TICKCONST</constant> ticks. This value |
63 | represents the ideal number of ticks between two non-delayed clock |
64 | represents the ideal number of ticks between two non-delayed clock |
64 | interrupts and has some known relation to real time. On each clock |
65 | interrupts and has some known relation to real time. On each clock |