examples_page.html.primary
来自「澳洲人写的Cortex,包括uC_IP协议栈」· PRIMARY 代码 · 共 250 行
PRIMARY
250 行
<HTML><HEAD><TITLE>CORTEX: V1.00.00: EXAMPLES</TITLE><BASE target="_top"><!-- Created by: Vadim Azarovsky, 24-Apr-1999 --><!-- Changed by: Vadim Azarovsky, 14-Mar-2000 --></HEAD><BODY><TABLE><TR><TD> <IMG align=middle border=0 src="icons/artesys_logo.gif"><TD> <IMG align=middle border=0 src="icons/cortex_logo.gif"><TD> <BIG><B>V1.00.00: EXAMPLES </B></BIG> </TR></TABLE><HR><!--<P align="center"><IMG src="icons/uconstr1.gif"></P><HR>--><p>This page contains links to examples available with the <B>CORTEX</B>distribution.<p><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl1/src/">Example 1: The Bounded Buffer Consumers and Producers (semaphore implementation)</A></BIG></B></I><P><DD>This program solves the bounded buffer producers and consumers problem with semaphores. This implementation is direct translationinto <I><B>CORTEX</B></I> environment of the classical semaphore solution presented in operation systems textbooks. <P>In this program, the semaphore <I>Mutex</I> is used to synchronize access to the shared variable <I>Count</I> in critical section of code where <I>Count</I> is updated. This semaphore is used for mutual exclusion synchronisation. The other two semaphores, <I>Elements</I> and <I>Spaces</I>, are used to synchronise the producer and consumer tasks so the producer doesn't try to put something into a full buffer and the consumer doesn't try to take something from an empty buffer. These semaphores are used for conditional synchronisation, also called event synchronisation.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl2/src/">Example 2: The Bounded Buffer Consumers and Producers (mutex & condition implementation)</A></BIG></B></I><P><DD>This program solves the bounded buffer producers and consumers problem with mutexes and conditions. <I>Mutex</I> is used to synchronise access to the shared variable <I>Count</I> in critical section of code where <I>Count</I> is updated. <I>NotFull</I> condition is used to block producers when the buffer if full. Consumers signal on <I>NotFull</I> condition every time when an item is taken from the buffer. <I>NotEmpty</I>condition is used to block consumers when the bounded buffer if empty.Producers signal on the <I>NotEmpty</I> condition every time a new item isdeposited.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl3/src">Example 3: The Dining Philosophers Problem (events implementation)</A></BIG></B></I><DD><P>This example demonstrates the solution of the classical synchronisationproblem posed and solved by Dijkstra in 1965. This time it's done withhelp of <I><B><A HREF="../doc/evn.html" target=_top>event flags</A></B></I>.While this implementation doesn't suffer of the well known diseasecalled <B>starvation</B>, but it restricts the total number of philosophersaround the table to 32.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl4/src">Example 4: The Semaphore With Timeout</A></BIG></B></I><DD><P>This example presents implementation of a semaphore primitive witha mutex and conditions. This semaphore is almost identical to thesemaphore provided by <I><B><A HREF="../doc/sem.html" target=_top>counting semaphores component</A></B></I> but allows to specify a <I><B>timeout interval</B></I> when waiting on the semaphore.Note that the standard semaphore implementation offers a better performance.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl5/src">Example 5: The Barrier Lock Implementation</A></BIG></B></I><DD><P>This example presents a barrier lock implementation. An application uses the barrier synchronisation primitive to ensure that all parallel processes have completed execution of a code block before permitting the processes to continue to the next block. The a participating parallel task arrives at a barrier it will wait untilall the participating tasks arrive. All tasks can proceed afterthe last participating task arrives at the barrier.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl6/src">Example 6: The Simple Event Flags</A></BIG></B></I><DD><P>Another implementation of the event flags primitive. While it's not that sophisticated and efficient as the standard <I><B><A HREF="../doc/evn.html" target=_top> event flags component</A></B></I> but it shows how <I>condition keys</I> can be used. Note that the <I><B><A HREF="../doc/mtx.html" target=_top>mutex</A></B></I> is used when the event flags object is created to exchange logical events between tasks and the <I><B><A HREF="../doc/mnt.html" target=_top>monitor</A></B></I> is used if events are send between <I>software interrupt service routines</I> and tasks.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl7/src">Example 7: The Sleeping Barber (counting and binary semaphoresimplementation)</A></BIG></B></I><DD><P>This example shows how to organise the hair cutting processfor few customers by the same barber to make a haircut ina room with a limited number of chairs. The counting semaphore is usedto organise access to the chairs, and the maximum semaphore's counter valueequals to the number of the chairs in the barber's room. One binary semaphore is used to organise the barber's service (hair cutting). Second binary semaphore is used to wake the barber to wait (it blocks on this binary semaphore when there are no customers in the waiting room). The last semaphoreis used by customers to wait for the end of the service.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl8/src">Example 8: The Readers and Writers Problem (mutex and condition implementation)</A></BIG></B></I><DD><P>This problem models access to a data base."Imagine a big data base,such as airline reservation system, with many competing processeswishing to read and write it. It is acceptable to have multipleprocesses reading the data base at the same time, but if one process iswriting (i.e., changing) the data base, no other processes may have accessto data base, not even readers".(Andrew S. Tanenbaum, OPERATING SYSTEMS:Design and Implementation, Prentice-Hall, 1987). A mutex is used byreaders to increment number of readers accessed to data base when a readerstarts to read the data base and to decrement that number after a readerfinished to read the data base. Reading itself is not protected by themutex. A reader checks this number after decrementing and ifit becomes 0, sends a signal to the condition that writers couldtry to write the data base. A writer writes data base in protected by themutex mode, that protects the data base from all readers and all otherwriters. Before starts to write the data base a writer checksthat counter of the data base readers is 0, and if it is notwaits on the condition a signal that all readers finishes to read thedata base. After received a signal a writer does start to write thedata base immediately ( this is very important ), it checks counterof readers again and writes if only this number is 0. An additionalchecking is needed because, between a time when a writer receives a signalsand a time it really acquires the mutex, a reader couldobtain the data base.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../doc/sdr.html">Example 9: Simple Serial Driver</A></BIG></B></I><DD><P>This example presents implementation of the simple hardware independentserial driver. This is CPU and serial device independent part of the serial driver. The driver requires serial device which contains all specificknowledge about particular serial chip. The following three examples present implementation of such serial devices for different hardware platforms.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../doc/aio.html">Example 10: Asynchronous Serial Device For POSIX.4 Platform</A></BIG></B></I><DD><P>This example presents the implementation of serial device for POSIX.4 environment.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../doc/hsd.html">Example 11: Serial Device For Hitachi H8300H On-chip UART</A></BIG></B></I><DD><P>The implementation of the serial device for Hitachi H8300H on-chip UART.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../doc/552.html">Example 12: Serial Device For 16C552 UART</A></BIG></B></I><DD><P>The implementation of the serial device for 16C552 UART. Tested on TI TMS320C31platform.</DL><P><HR><P><DL><DT><I><B><BIG><A HREF="../examples/exmpl13/src">Example 13: How to setup uC/IP TCP/IP/PPP stack</A></BIG></B></I><DD><P>This example demonstrates how to setup <I><B><A HREF="../doc/ucip.html" target=_top>uC/IP TCP/IP/PPP</A></B></I> stack.</DL><P><HR><P></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?