Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HttpServer TextLCD expatlib mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip
Fork of giken9_HTMLServer_Sample by
mbed-rtos/rtx/rt_Robin.c@0:7766f6712673, 2014-03-12 (annotated)
- Committer:
 - yueee_yt
 - Date:
 - Wed Mar 12 04:19:54 2014 +0000
 - Revision:
 - 0:7766f6712673
 
???????????????
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| yueee_yt | 0:7766f6712673 | 1 | /*---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 2 | * RL-ARM - RTX | 
| yueee_yt | 0:7766f6712673 | 3 | *---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 4 | * Name: RT_ROBIN.C | 
| yueee_yt | 0:7766f6712673 | 5 | * Purpose: Round Robin Task switching | 
| yueee_yt | 0:7766f6712673 | 6 | * Rev.: V4.60 | 
| yueee_yt | 0:7766f6712673 | 7 | *---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 8 | * | 
| yueee_yt | 0:7766f6712673 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH | 
| yueee_yt | 0:7766f6712673 | 10 | * All rights reserved. | 
| yueee_yt | 0:7766f6712673 | 11 | * Redistribution and use in source and binary forms, with or without | 
| yueee_yt | 0:7766f6712673 | 12 | * modification, are permitted provided that the following conditions are met: | 
| yueee_yt | 0:7766f6712673 | 13 | * - Redistributions of source code must retain the above copyright | 
| yueee_yt | 0:7766f6712673 | 14 | * notice, this list of conditions and the following disclaimer. | 
| yueee_yt | 0:7766f6712673 | 15 | * - Redistributions in binary form must reproduce the above copyright | 
| yueee_yt | 0:7766f6712673 | 16 | * notice, this list of conditions and the following disclaimer in the | 
| yueee_yt | 0:7766f6712673 | 17 | * documentation and/or other materials provided with the distribution. | 
| yueee_yt | 0:7766f6712673 | 18 | * - Neither the name of ARM nor the names of its contributors may be used | 
| yueee_yt | 0:7766f6712673 | 19 | * to endorse or promote products derived from this software without | 
| yueee_yt | 0:7766f6712673 | 20 | * specific prior written permission. | 
| yueee_yt | 0:7766f6712673 | 21 | * | 
| yueee_yt | 0:7766f6712673 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
| yueee_yt | 0:7766f6712673 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| yueee_yt | 0:7766f6712673 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
| yueee_yt | 0:7766f6712673 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE | 
| yueee_yt | 0:7766f6712673 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
| yueee_yt | 0:7766f6712673 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
| yueee_yt | 0:7766f6712673 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| yueee_yt | 0:7766f6712673 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| yueee_yt | 0:7766f6712673 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
| yueee_yt | 0:7766f6712673 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
| yueee_yt | 0:7766f6712673 | 32 | * POSSIBILITY OF SUCH DAMAGE. | 
| yueee_yt | 0:7766f6712673 | 33 | *---------------------------------------------------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 34 | |
| yueee_yt | 0:7766f6712673 | 35 | #include "rt_TypeDef.h" | 
| yueee_yt | 0:7766f6712673 | 36 | #include "RTX_Conf.h" | 
| yueee_yt | 0:7766f6712673 | 37 | #include "rt_List.h" | 
| yueee_yt | 0:7766f6712673 | 38 | #include "rt_Task.h" | 
| yueee_yt | 0:7766f6712673 | 39 | #include "rt_Time.h" | 
| yueee_yt | 0:7766f6712673 | 40 | #include "rt_Robin.h" | 
| yueee_yt | 0:7766f6712673 | 41 | #include "rt_HAL_CM.h" | 
| yueee_yt | 0:7766f6712673 | 42 | |
| yueee_yt | 0:7766f6712673 | 43 | /*---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 44 | * Global Variables | 
| yueee_yt | 0:7766f6712673 | 45 | *---------------------------------------------------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 46 | |
| yueee_yt | 0:7766f6712673 | 47 | struct OS_ROBIN os_robin; | 
| yueee_yt | 0:7766f6712673 | 48 | |
| yueee_yt | 0:7766f6712673 | 49 | |
| yueee_yt | 0:7766f6712673 | 50 | /*---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 51 | * Global Functions | 
| yueee_yt | 0:7766f6712673 | 52 | *---------------------------------------------------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 53 | |
| yueee_yt | 0:7766f6712673 | 54 | /*--------------------------- rt_init_robin ---------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 55 | |
| yueee_yt | 0:7766f6712673 | 56 | __weak void rt_init_robin (void) { | 
| yueee_yt | 0:7766f6712673 | 57 | /* Initialize Round Robin variables. */ | 
| yueee_yt | 0:7766f6712673 | 58 | os_robin.task = NULL; | 
| yueee_yt | 0:7766f6712673 | 59 | os_robin.tout = (U16)os_rrobin; | 
| yueee_yt | 0:7766f6712673 | 60 | } | 
| yueee_yt | 0:7766f6712673 | 61 | |
| yueee_yt | 0:7766f6712673 | 62 | /*--------------------------- rt_chk_robin ----------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 63 | |
| yueee_yt | 0:7766f6712673 | 64 | __weak void rt_chk_robin (void) { | 
| yueee_yt | 0:7766f6712673 | 65 | /* Check if Round Robin timeout expired and switch to the next ready task.*/ | 
| yueee_yt | 0:7766f6712673 | 66 | P_TCB p_new; | 
| yueee_yt | 0:7766f6712673 | 67 | |
| yueee_yt | 0:7766f6712673 | 68 | if (os_robin.task != os_rdy.p_lnk) { | 
| yueee_yt | 0:7766f6712673 | 69 | /* New task was suspended, reset Round Robin timeout. */ | 
| yueee_yt | 0:7766f6712673 | 70 | os_robin.task = os_rdy.p_lnk; | 
| yueee_yt | 0:7766f6712673 | 71 | os_robin.time = (U16)os_time + os_robin.tout - 1; | 
| yueee_yt | 0:7766f6712673 | 72 | } | 
| yueee_yt | 0:7766f6712673 | 73 | if (os_robin.time == (U16)os_time) { | 
| yueee_yt | 0:7766f6712673 | 74 | /* Round Robin timeout has expired, swap Robin tasks. */ | 
| yueee_yt | 0:7766f6712673 | 75 | os_robin.task = NULL; | 
| yueee_yt | 0:7766f6712673 | 76 | p_new = rt_get_first (&os_rdy); | 
| yueee_yt | 0:7766f6712673 | 77 | rt_put_prio ((P_XCB)&os_rdy, p_new); | 
| yueee_yt | 0:7766f6712673 | 78 | } | 
| yueee_yt | 0:7766f6712673 | 79 | } | 
| yueee_yt | 0:7766f6712673 | 80 | |
| yueee_yt | 0:7766f6712673 | 81 | /*---------------------------------------------------------------------------- | 
| yueee_yt | 0:7766f6712673 | 82 | * end of file | 
| yueee_yt | 0:7766f6712673 | 83 | *---------------------------------------------------------------------------*/ | 
| yueee_yt | 0:7766f6712673 | 84 | 
