Skip to content

Commit ea9a44f

Browse files
committed
Add yield within API macro
* Add yield within API macro for readibility
1 parent 8e898b7 commit ea9a44f

File tree

4 files changed

+35
-91
lines changed

4 files changed

+35
-91
lines changed

event_groups.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
* correct privileged Vs unprivileged linkage and placement. */
4747
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021 See comment above. */
4848

49+
#if ( configNUMBER_OF_CORES == 1 )
50+
#define eventgroupYIELD_WITHIN_API() portYIELD_WITHIN_API()
51+
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
52+
#define eventgroupYIELD_WITHIN_API() vTaskYieldWithinAPI()
53+
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
54+
4955
typedef struct EventGroupDef_t
5056
{
5157
EventBits_t uxEventBits;
@@ -243,15 +249,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
243249
{
244250
if( xAlreadyYielded == pdFALSE )
245251
{
246-
#if ( configNUMBER_OF_CORES == 1 )
247-
{
248-
portYIELD_WITHIN_API();
249-
}
250-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
251-
{
252-
vTaskYieldWithinAPI();
253-
}
254-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
252+
eventgroupYIELD_WITHIN_API();
255253
}
256254
else
257255
{
@@ -403,15 +401,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
403401
{
404402
if( xAlreadyYielded == pdFALSE )
405403
{
406-
#if ( configNUMBER_OF_CORES == 1 )
407-
{
408-
portYIELD_WITHIN_API();
409-
}
410-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
411-
{
412-
vTaskYieldWithinAPI();
413-
}
414-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
404+
eventgroupYIELD_WITHIN_API();
415405
}
416406
else
417407
{

queue.c

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ typedef struct SemaphoreData
9696
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
9797
#endif
9898

99+
#if ( configNUMBER_OF_CORES == 1 )
100+
#define queueYIELD_WITHIN_API() portYIELD_WITHIN_API()
101+
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
102+
#define queueYIELD_WITHIN_API() vTaskYieldWithinAPI()
103+
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
104+
99105
/*
100106
* Definition of the queue used by the scheduler.
101107
* Items are queued by copy, not reference. See the following link for the
@@ -1074,15 +1080,7 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
10741080
* is also a higher priority task in the pending ready list. */
10751081
if( xTaskResumeAll() == pdFALSE )
10761082
{
1077-
#if ( configNUMBER_OF_CORES == 1 )
1078-
{
1079-
portYIELD_WITHIN_API();
1080-
}
1081-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1082-
{
1083-
vTaskYieldWithinAPI();
1084-
}
1085-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1083+
queueYIELD_WITHIN_API();
10861084
}
10871085
}
10881086
else
@@ -1543,15 +1541,7 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue,
15431541

15441542
if( xTaskResumeAll() == pdFALSE )
15451543
{
1546-
#if ( configNUMBER_OF_CORES == 1 )
1547-
{
1548-
portYIELD_WITHIN_API();
1549-
}
1550-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1551-
{
1552-
vTaskYieldWithinAPI();
1553-
}
1554-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1544+
queueYIELD_WITHIN_API();
15551545
}
15561546
else
15571547
{
@@ -1734,15 +1724,7 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
17341724

17351725
if( xTaskResumeAll() == pdFALSE )
17361726
{
1737-
#if ( configNUMBER_OF_CORES == 1 )
1738-
{
1739-
portYIELD_WITHIN_API();
1740-
}
1741-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1742-
{
1743-
vTaskYieldWithinAPI();
1744-
}
1745-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1727+
queueYIELD_WITHIN_API();
17461728
}
17471729
else
17481730
{
@@ -1920,15 +1902,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue,
19201902

19211903
if( xTaskResumeAll() == pdFALSE )
19221904
{
1923-
#if ( configNUMBER_OF_CORES == 1 )
1924-
{
1925-
portYIELD_WITHIN_API();
1926-
}
1927-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
1928-
{
1929-
vTaskYieldWithinAPI();
1930-
}
1931-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
1905+
queueYIELD_WITHIN_API();
19321906
}
19331907
else
19341908
{

tasks.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
#endif
7070
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
7171

72+
#if ( configNUMBER_OF_CORES == 1 )
73+
#define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
74+
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
75+
#define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
76+
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
77+
7278
/* Values that can be assigned to the ucNotifyState member of the TCB. */
7379
#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 ) /* Must be zero as it is the initialised value. */
7480
#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )
@@ -2095,11 +2101,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20952101
* have put ourselves to sleep. */
20962102
if( xAlreadyYielded == pdFALSE )
20972103
{
2098-
#if ( configNUMBER_OF_CORES == 1 )
2099-
portYIELD_WITHIN_API();
2100-
#else
2101-
vTaskYieldWithinAPI();
2102-
#endif
2104+
taskYIELD_WITHIN_API();
21032105
}
21042106
else
21052107
{
@@ -2147,11 +2149,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
21472149
* have put ourselves to sleep. */
21482150
if( xAlreadyYielded == pdFALSE )
21492151
{
2150-
#if ( configNUMBER_OF_CORES == 1 )
2151-
portYIELD_WITHIN_API();
2152-
#else
2153-
vTaskYieldWithinAPI();
2154-
#endif
2152+
taskYIELD_WITHIN_API();
21552153
}
21562154
else
21572155
{
@@ -6814,15 +6812,7 @@ TickType_t uxTaskResetEventItemValue( void )
68146812
* section (some will yield immediately, others wait until the
68156813
* critical section exits) - but it is not something that
68166814
* application code should ever do. */
6817-
#if ( configNUMBER_OF_CORES == 1 )
6818-
{
6819-
portYIELD_WITHIN_API();
6820-
}
6821-
#else
6822-
{
6823-
vTaskYieldWithinAPI();
6824-
}
6825-
#endif
6815+
taskYIELD_WITHIN_API();
68266816
}
68276817
else
68286818
{
@@ -6901,15 +6891,7 @@ TickType_t uxTaskResetEventItemValue( void )
69016891
* section (some will yield immediately, others wait until the
69026892
* critical section exits) - but it is not something that
69036893
* application code should ever do. */
6904-
#if ( configNUMBER_OF_CORES == 1 )
6905-
{
6906-
portYIELD_WITHIN_API();
6907-
}
6908-
#else
6909-
{
6910-
vTaskYieldWithinAPI();
6911-
}
6912-
#endif
6894+
taskYIELD_WITHIN_API();
69136895
}
69146896
else
69156897
{

timers.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( 0x02U )
7272
#define tmrSTATUS_IS_AUTORELOAD ( 0x04U )
7373

74+
#if ( configNUMBER_OF_CORES == 1 )
75+
#define timerYIELD_WITHIN_API() portYIELD_WITHIN_API()
76+
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
77+
#define timerYIELD_WITHIN_API() vTaskYieldWithinAPI()
78+
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
79+
7480
/* The definition of the timers themselves. */
7581
typedef struct tmrTimerControl /* The old naming convention is used to prevent breaking kernel aware debuggers. */
7682
{
@@ -710,15 +716,7 @@
710716
* block time to expire. If a command arrived between the
711717
* critical section being exited and this yield then the yield
712718
* will not cause the task to block. */
713-
#if ( configNUMBER_OF_CORES == 1 )
714-
{
715-
portYIELD_WITHIN_API();
716-
}
717-
#else /* #if ( configNUMBER_OF_CORES == 1 ) */
718-
{
719-
vTaskYieldWithinAPI();
720-
}
721-
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
719+
timerYIELD_WITHIN_API();
722720
}
723721
else
724722
{

0 commit comments

Comments
 (0)