version 1.1.1.1, 2008/06/03 10:38:43 |
version 1.1.1.1.2.1, 2008/08/13 17:12:26 |
|
|
<td id="logo">
|
<td id="logo">
|
<a href="http://prex.sourceforge.net/">
|
<a href="http://prex.sourceforge.net/">
|
<img alt="Prex logo" src="../img/logo.gif" border="0"
|
<img alt="Prex logo" src="../img/logo.gif" border="0"
|
style="width: 281px; height: 56px;"></a>
|
style="width: 250px; height: 54px;"></a>
|
</td>
|
</td>
|
<td id="brief" align="right" valign="bottom">
|
<td id="brief" align="right" valign="bottom">
|
An Open Source, Royalty-free,<br>
|
An Open Source, Royalty-free,<br>
|
|
|
<tr><td class="pad" colspan="2" style="vertical-align: top;"></td></tr>
|
<tr><td class="pad" colspan="2" style="vertical-align: top;"></td></tr>
|
|
|
<tr>
|
<tr>
|
<td id="main" style="vertical-align: top;">
|
<td id="doc" style="vertical-align: top;">
|
|
|
<h1>Prex Kernel Internals</h1>
|
<h1>Prex Kernel Internals</h1>
|
|
|
<i>Version 1.4, 2005/12/31</i>
|
<i>Version 1.4, 2005/12/31</i>
|
|
|
int state; /* thread state */
|
int state; /* thread state */
|
int policy; /* scheduling policy */
|
int policy; /* scheduling policy */
|
int prio; /* current priority */
|
int prio; /* current priority */
|
int base_prio; /* base priority */
|
int baseprio; /* base priority */
|
int ticks_left; /* remaining ticks to run */
|
int timeleft; /* remaining ticks to run */
|
u_int total_ticks; /* total running ticks */
|
u_int time; /* total running time */
|
int need_resched; /* true if rescheduling is needed */
|
int resched; /* true if rescheduling is needed */
|
int lock_count; /* schedule lock counter */
|
int locks; /* schedule lock counter */
|
int suspend_count; /* suspend counter */
|
int suscnt; /* suspend counter */
|
struct event *sleep_event; /* sleep event */
|
struct event *slpevt; /* sleep event */
|
int sleep_result; /* sleep result */
|
int slpret; /* sleep result code */
|
struct timer timeout; /* thread timer */
|
struct timer timeout; /* thread timer */
|
struct timer *periodic; /* pointer to periodic timer */
|
struct timer *periodic; /* pointer to periodic timer */
|
|
uint32_t excbits; /* bitmap of pending exceptions */
|
struct queue ipc_link; /* linkage on IPC queue */
|
struct queue ipc_link; /* linkage on IPC queue */
|
void *msg_addr; /* kernel address of IPC message */
|
void *msgaddr; /* kernel address of IPC message */
|
size_t msg_size; /* size of IPC message */
|
size_t msgsize; /* size of IPC message */
|
struct thread *sender; /* thread that sends IPC message */
|
thread_t sender; /* thread that sends IPC message */
|
struct thread *receiver; /* thread that receives IPC message */
|
thread_t receiver; /* thread that receives IPC message */
|
object_t send_obj; /* IPC object sending to */
|
object_t sendobj; /* IPC object sending to */
|
object_t recv_obj; /* IPC object receiving from */
|
object_t recvobj; /* IPC object receiving from */
|
uint32_t exc_bitmap; /* bitmap of pending exceptions */
|
|
struct list mutexes; /* mutexes locked by this thread */
|
struct list mutexes; /* mutexes locked by this thread */
|
struct mutex *wait_mutex; /* mutex pointer currently waiting */
|
struct mutex *wait_mutex; /* mutex pointer currently waiting */
|
void *kstack; /* base address of kernel stack */
|
void *kstack; /* base address of kernel stack */
|
struct context context; /* machine specific context */
|
struct context ctx; /* machine specific context */
|
};</pre>
|
};</pre>
|
|
|
<h3>Thread Creation</h3>
|
<h3>Thread Creation</h3>
|
|
|
<p>
|
<p>
|
Each thread has one of the following states.
|
Each thread has one of the following states.
|
</p>
|
</p>
|
|
<p>
|
|
<img alt="Memory Structure" src="img/thread.gif" border="1"
|
|
style="width: 430px; height: 314px;"><br>
|
|
|
|
<i><b>Figure 2. Thread States</b></i>
|
|
</p>
|
|
|
<ul>
|
<ul>
|
<li><b>RUN</b> :Running or ready to run</li>
|
<li><b>RUN</b> :Running or ready to run</li>
|
<li><b>SLEEP</b> :Sleep for some event</li>
|
<li><b>SLEEP</b> :Sleep for some event</li>
|
|
|
</tbody>
|
</tbody>
|
</table>
|
</table>
|
|
|
|
|
<h3>Scheduling Policy</h3>
|
<h3>Scheduling Policy</h3>
|
<p>
|
<p>
|
There are following three types of scheduling policy.
|
There are following three types of scheduling policy.
|
|
|
<img alt="Memory Structure" src="img/memory.gif" border="1"
|
<img alt="Memory Structure" src="img/memory.gif" border="1"
|
style="width: 448px; height: 308px;"><br>
|
style="width: 448px; height: 308px;"><br>
|
|
|
<i><b>Figure 2. Prex Memory Structure</b></i>
|
<i><b>Figure 3. Prex Memory Structure</b></i>
|
</p>
|
</p>
|
<p>
|
<p>
|
The key point is that Prex kernel does not page out to
|
The key point is that Prex kernel does not page out to
|
|
|
<img alt="Memory Mapping" src="img/memmap.gif" border="1"
|
<img alt="Memory Mapping" src="img/memmap.gif" border="1"
|
style="width: 504px; height: 271px;"><br>
|
style="width: 504px; height: 271px;"><br>
|
|
|
<i><b>Figure 3. Kernel Memory Mapping</b></i>
|
<i><b>Figure 4. Kernel Memory Mapping</b></i>
|
</p>
|
</p>
|
|
|
<p>
|
<p>
|
|
|
<img alt="ipc queue" src="img/msg.gif" border="1"
|
<img alt="ipc queue" src="img/msg.gif" border="1"
|
style="width: 505px; height: 347px;"><br>
|
style="width: 505px; height: 347px;"><br>
|
|
|
<i><b>Figure 4. IPC Transmit Sequence</b></i>
|
<i><b>Figure 5. IPC Transmit Sequence</b></i>
|
|
|
<h3>Message Transfer</h3>
|
<h3>Message Transfer</h3>
|
<p>
|
<p>
|
|
|
<img alt="Message transfer" src="img/ipcmap.gif" border="1"
|
<img alt="Message transfer" src="img/ipcmap.gif" border="1"
|
style="width: 459px; height: 321px;"><br>
|
style="width: 459px; height: 321px;"><br>
|
|
|
<i><b>Figure 5. IPC message transfer</b></i>
|
<i><b>Figure 6. IPC message transfer</b></i>
|
|
|
<h2 id="except">Exception Handling</h2>
|
<h2 id="except">Exception Handling</h2>
|
<p>
|
<p>
|
|
|
</p>
|
</p>
|
<p>
|
<p>
|
<img alt="Interrupt Processing" src="img/irq.gif" border="1"><br>
|
<img alt="Interrupt Processing" src="img/irq.gif" border="1"><br>
|
<i><b>Figure 6. Prex Interrupt Processing</b></i>
|
<i><b>Figure 7. Prex Interrupt Processing</b></i>
|
</p>
|
</p>
|
<p>
|
<p>
|
</p>
|
</p>
|
|
|
<h2 id="debug">Debug</h2>
|
<h2 id="debug">Debug</h2>
|
There are following debugging support functions:
|
There are following debugging support functions:
|
<ul>
|
<ul>
|
<li>printk(): Display the debug message in kernel.</li>
|
<li>printf(): Display the debug message in kernel.</li>
|
<li>panic(): Dump processor registers and stop system.</li>
|
<li>panic(): Dump processor registers and stop system.</li>
|
<li>ASSERT(): If expression is false (zero), stop system and display information.</li>
|
<li>ASSERT(): If expression is false (zero), stop system and display information.</li>
|
<li>trace_on(): If the kernel trace is enabled, all entry/exit of functions
|
<li>trace_on(): If the kernel trace is enabled, all entry/exit of functions
|