LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
os_prio.c
Go to the documentation of this file.
1
/*
2
************************************************************************************************************************
3
* uC/OS-III
4
* The Real-Time Kernel
5
*
6
* (c) Copyright 2009-2012; Micrium, Inc.; Weston, FL
7
* All rights reserved. Protected by international copyright laws.
8
*
9
* PRIORITY MANAGEMENT
10
*
11
* File : OS_PRIO.C
12
* By : JJL
13
* Version : V3.03.00
14
*
15
* LICENSING TERMS:
16
* ---------------
17
* uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or
18
* for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/
19
* product then, you need to contact Micrium to properly license uC/OS-III for its use in your
20
* application/product. We provide ALL the source code for your convenience and to help you
21
* experience uC/OS-III. The fact that the source is provided does NOT mean that you can use
22
* it commercially without paying a licensing fee.
23
*
24
* Knowledge of the source code may NOT be used to develop a similar product.
25
*
26
* Please help us continue to provide the embedded community with the finest software available.
27
* Your honesty is greatly appreciated.
28
*
29
* You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036.
30
************************************************************************************************************************
31
*/
32
33
#define MICRIUM_SOURCE
34
#include <
os.h
>
35
36
#ifdef VSC_INCLUDE_SOURCE_FILE_NAMES
37
const
CPU_CHAR
*os_prio__c =
"$Id: $"
;
38
#endif
39
40
41
CPU_DATA
OSPrioTbl
[
OS_PRIO_TBL_SIZE
];
/* Declare the array local to this file to allow for ... */
42
/* ... optimization. In other words, this allows the ... */
43
/* ... table to be located in fast memory */
44
45
/*
46
************************************************************************************************************************
47
* INITIALIZE THE PRIORITY LIST
48
*
49
* Description: This function is called by uC/OS-III to initialize the list of ready priorities.
50
*
51
* Arguments : none
52
*
53
* Returns : none
54
*
55
* Note : This function is INTERNAL to uC/OS-III and your application should not call it.
56
************************************************************************************************************************
57
*/
58
59
void
OS_PrioInit
(
void
)
60
{
61
CPU_DATA
i;
62
63
64
/* Clear the bitmap table ... no task is ready */
65
for
(i = 0u; i <
OS_PRIO_TBL_SIZE
; i++) {
66
OSPrioTbl
[i] = (
CPU_DATA
)0;
67
}
68
}
69
70
/*
71
************************************************************************************************************************
72
* GET HIGHEST PRIORITY TASK WAITING
73
*
74
* Description: This function is called by other uC/OS-III services to determine the highest priority task
75
* waiting on the event.
76
*
77
* Arguments : none
78
*
79
* Returns : The priority of the Highest Priority Task (HPT) waiting for the event
80
*
81
* Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
82
************************************************************************************************************************
83
*/
84
85
OS_PRIO
OS_PrioGetHighest
(
void
)
86
{
87
CPU_DATA
*p_tbl;
88
OS_PRIO
prio;
89
90
91
prio = (
OS_PRIO
)0;
92
p_tbl = &
OSPrioTbl
[0];
93
while
(*p_tbl == (
CPU_DATA
)0) {
/* Search the bitmap table for the highest priority */
94
prio +=
DEF_INT_CPU_NBR_BITS
;
/* Compute the step of each CPU_DATA entry */
95
p_tbl++;
96
}
97
prio += (
OS_PRIO
)
CPU_CntLeadZeros
(*p_tbl);
/* Find the position of the first bit set at the entry */
98
return
(prio);
99
}
100
101
/*
102
************************************************************************************************************************
103
* INSERT PRIORITY
104
*
105
* Description: This function is called to insert a priority in the priority table.
106
*
107
* Arguments : prio is the priority to insert
108
*
109
* Returns : none
110
*
111
* Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
112
************************************************************************************************************************
113
*/
114
115
void
OS_PrioInsert
(
OS_PRIO
prio)
116
{
117
CPU_DATA
bit;
118
CPU_DATA
bit_nbr;
119
OS_PRIO
ix;
120
121
122
ix = prio /
DEF_INT_CPU_NBR_BITS
;
123
bit_nbr = (
CPU_DATA
)prio & (
DEF_INT_CPU_NBR_BITS
- 1u);
124
bit = 1u;
125
bit <<= (
DEF_INT_CPU_NBR_BITS
- 1u) - bit_nbr;
126
OSPrioTbl
[ix] |= bit;
127
}
128
129
/*
130
************************************************************************************************************************
131
* REMOVE PRIORITY
132
*
133
* Description: This function is called to remove a priority in the priority table.
134
*
135
* Arguments : prio is the priority to remove
136
*
137
* Returns : none
138
*
139
* Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
140
************************************************************************************************************************
141
*/
142
143
void
OS_PrioRemove
(
OS_PRIO
prio)
144
{
145
CPU_DATA
bit;
146
CPU_DATA
bit_nbr;
147
OS_PRIO
ix;
148
149
150
ix = prio /
DEF_INT_CPU_NBR_BITS
;
151
bit_nbr = (
CPU_DATA
)prio & (
DEF_INT_CPU_NBR_BITS
- 1u);
152
bit = 1u;
153
bit <<= (
DEF_INT_CPU_NBR_BITS
- 1u) - bit_nbr;
154
OSPrioTbl
[ix] &= ~bit;
155
}
software
ucos_iii
Micrium
Software
uCOS-III
Source
os_prio.c
Generated on Fri May 10 2013 10:42:27 for LPCOpen Platform by
1.8.2