gThreadpriorityLow/Normal/High to replace LOW_/NORMAL_/HIGH_PRIORITY

This commit is contained in:
inmarket 2018-07-08 15:32:26 +10:00
parent 93da5a0578
commit 1fc4180d41
30 changed files with 70 additions and 67 deletions

View File

@ -19,7 +19,7 @@ CHANGE: Added type gBool to replace V2.x bool_t, and values gT
CHANGE: Added type gDelay to replace V2.x delaytime_t and values gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE
CHANGE: Added type gTicks to replace V2.x systemticks_t
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t and values gThreadpriorityLow/Normal/High to replace LOW_/NORMAL_/HIGH_PRIORITY
CHANGE: Added type gPoint to replace V2.x point and point_t
CHANGE: Added type gCoord to replace V2.x coord_t
CHANGE: Added type gPixel to replace V2.x pixel_t

View File

@ -38,7 +38,7 @@
#include "notepadCore.h"
#include "notepadUIDefines.h"
#define NPAD_THD_PRIO NORMAL_PRIORITY
#define NPAD_THD_PRIO gThreadpriorityNormal
#define NPAD_THD_WA_SIZE 512
void nSetColorScheme(NColorScheme sch);

View File

@ -37,7 +37,7 @@
/* Configuration */
#define NCORE_THD_STACK_SIZE 256
#define NCORE_THD_PRIO NORMAL_PRIORITY
#define NCORE_THD_PRIO gThreadpriorityNormal
#define NCORE_MODE_DRAW 0
#define NCORE_MODE_ERASE 1

View File

@ -153,7 +153,7 @@ void doBounce(GHandle parent, gBool start) {
if (start) {
run = gTrue;
gh = parent;
thread = gfxThreadCreate(0, 0x200, LOW_PRIORITY, task, 0);
thread = gfxThreadCreate(0, 0x200, gThreadpriorityLow, task, 0);
} else if (run) {
run = gFalse;
gfxThreadWait(thread);

View File

@ -89,7 +89,7 @@ void doMandlebrot(GHandle parent, gBool start) {
if (start) {
run = gTrue;
gh = parent;
thread = gfxThreadCreate(0, 0x400, LOW_PRIORITY, task, 0);
thread = gfxThreadCreate(0, 0x400, gThreadpriorityLow, task, 0);
} else if (run) {
run = gFalse;
gfxThreadWait(thread);

View File

@ -460,7 +460,7 @@ void jg10Start(void) {
#endif
initField();
guiCreate();
gfxThreadCreate(0, 1024, NORMAL_PRIORITY, thdJg10, 0);
gfxThreadCreate(0, 1024, gThreadpriorityNormal, thdJg10, 0);
while (!jg10GameOver) {
gfxSleepMilliseconds(100);
}

View File

@ -382,7 +382,7 @@ void minesStart(void)
#endif
initField();
gfxThreadCreate(0, 1024, NORMAL_PRIORITY, thdMines, 0);
gfxThreadCreate(0, 1024, gThreadpriorityNormal, thdMines, 0);
while (!minesGameOver) {
gfxSleepMilliseconds(100);
}

View File

@ -498,7 +498,7 @@ void tetrisStart(void) {
tetrisGameOver = gFalse;
printGameOver(); // removes "Game Over!" if tetrisGameOver == gFalse
tetrisPreviousGameTime = gfxSystemTicks();
gfxThreadCreate(0, 1024, NORMAL_PRIORITY, thdTetris, 0);
gfxThreadCreate(0, 1024, gThreadpriorityNormal, thdTetris, 0);
while (!tetrisGameOver) {
gfxSleepMilliseconds(1000);
}

View File

@ -51,8 +51,8 @@ int main(void)
gfxInit();
// Give this plenty of stack. Stack size optimisation should be a production change only
gfxThreadCreate(0, 2048, NORMAL_PRIORITY, heartbeat1, 0);
gfxThreadCreate(0, 2048, NORMAL_PRIORITY, heartbeat2, 0);
gfxThreadCreate(0, 2048, gThreadpriorityNormal, heartbeat1, 0);
gfxThreadCreate(0, 2048, gThreadpriorityNormal, heartbeat2, 0);
while (1) {
DEBUGWRITE("thread main\n");

View File

@ -107,7 +107,7 @@ int main(void)
/* Create a static thread from the default heap with normal priority.
* We pass a the parameter to the thread which tells the thread whether to return or not
*/
thd = gfxThreadCreate(NULL, 2048, NORMAL_PRIORITY, Thread_function, (void*)&exitThread);
thd = gfxThreadCreate(NULL, 2048, gThreadpriorityNormal, Thread_function, (void*)&exitThread);
/* Start the timer. The callback function will be called once after 2000ms
* We will pass the thread handle as a parameter so the timer can ask the thread to terminate

View File

@ -81,7 +81,7 @@
#define StartSockets() Start_LWIP();
#else
#include "lwipthread.h"
#define StartSockets() gfxThreadClose(gfxThreadCreate(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMAL_PRIORITY, lwip_thread, 0))
#define StartSockets() gfxThreadClose(gfxThreadCreate(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, gThreadpriorityNormal, lwip_thread, 0))
#endif
#if !LWIP_SOCKET
@ -358,7 +358,7 @@ int main(proto_args) {
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
// Start the mouse thread if needed
if (cmd[3])
gfxThreadClose(gfxThreadCreate(waNetThread, sizeof(waNetThread), HIGH_PRIORITY, NetThread, 0));
gfxThreadClose(gfxThreadCreate(waNetThread, sizeof(waNetThread), gThreadpriorityHigh, NetThread, 0));
#endif
// Process incoming instructions

View File

@ -330,7 +330,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#endif
fprintf(stderr, "Running GFX Window in %d bit color\n", vis.depth);
if (!(hth = gfxThreadCreate(waXThread, sizeof(waXThread), HIGH_PRIORITY, ThreadX, 0))) {
if (!(hth = gfxThreadCreate(waXThread, sizeof(waXThread), gThreadpriorityHigh, ThreadX, 0))) {
fprintf(stderr, "Cannot start X Thread\n");
XCloseDisplay(dis);
exit(0);

View File

@ -124,7 +124,7 @@
#define StartSockets() Start_LWIP();
#else
#include "lwipthread.h"
#define StartSockets() gfxThreadClose(gfxThreadCreate(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMAL_PRIORITY, lwip_thread, 0))
#define StartSockets() gfxThreadClose(gfxThreadCreate(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, gThreadpriorityNormal, lwip_thread, 0))
#endif
#if !LWIP_SOCKET
@ -435,7 +435,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
// Initialise the receiver thread (if it hasn't been done already)
if (!hThread) {
MUTEX_INIT;
hThread = gfxThreadCreate(waNetThread, sizeof(waNetThread), HIGH_PRIORITY, NetThread, 0);
hThread = gfxThreadCreate(waNetThread, sizeof(waNetThread), gThreadpriorityHigh, NetThread, 0);
gfxThreadClose(hThread);
}

View File

@ -264,7 +264,7 @@
///////////////////////////////////////////////////////////////////////////
//#define GFX_USE_GTIMER GFXOFF
//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
//#define GTIMER_THREAD_PRIORITY gThreadpriorityHigh
//#define GTIMER_THREAD_WORKAREA_SIZE 2048

View File

@ -99,12 +99,12 @@
* @note Your platform may use slightly different definitions to these
* @{
*/
#define gDelayNone 0
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 2
#define gThreadpriorityLow 0
#define gThreadpriorityNormal 1
#define gThreadpriorityHigh 2
/** @} */
/**
@ -495,14 +495,17 @@
#if GFX_COMPAT_V2
typedef gDelay delaytime_t;
#if !GFX_USE_OS_CHIBIOS
// These values are defined by ChibiOS itself
#define TIME_IMMEDIATE gDelayNone
#define TIME_INFINITE gDelayForever
#endif
typedef gTicks systemticks_t;
typedef gThreadreturn threadreturn_t;
typedef gThreadpriority threadpriority_t;
#if !GFX_USE_OS_CHIBIOS
// These are defined by ChibiOS itself
#define TIME_IMMEDIATE gDelayNone
#define TIME_INFINITE gDelayForever
#endif
#define LOW_PRIORITY gThreadpriorityLow
#define NORMAL_PRIORITY gThreadpriorityNormal
#define HIGH_PRIORITY gThreadpriorityHigh
#endif
#endif /* _GOS_H */

View File

@ -39,9 +39,9 @@ typedef msg_t gThreadreturn;
typedef tprio_t gThreadpriority;
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY LOWPRIO
#define NORMAL_PRIORITY NORMALPRIO
#define HIGH_PRIORITY HIGHPRIO
#define gThreadpriorityLow LOWPRIO
#define gThreadpriorityNormal NORMALPRIO
#define gThreadpriorityHigh HIGHPRIO
#define DECLARE_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)

View File

@ -34,9 +34,9 @@ typedef void gThreadreturn;
typedef osPriority gThreadpriority;
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
#define LOW_PRIORITY osPriorityLow
#define NORMAL_PRIORITY osPriorityNormal
#define HIGH_PRIORITY osPriorityHigh
#define gThreadpriorityLow osPriorityLow
#define gThreadpriorityNormal osPriorityNormal
#define gThreadpriorityHigh osPriorityHigh
typedef struct gfxSem {
uint32_t semaphore[2];

View File

@ -44,12 +44,12 @@ void _gosPostInit(void)
osKernelInitialize();
/* Fall Through */
case osKernelReady:
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, NORMAL_PRIORITY, startUGFX_CMSIS2, 0);
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, gThreadpriorityNormal, startUGFX_CMSIS2, 0);
osKernelStart();
gfxHalt("Unable to start CMSIS V2 scheduler. Out of memory?");
break;
default:
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, NORMAL_PRIORITY, startUGFX_CMSIS2, 0);
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, gThreadpriorityNormal, startUGFX_CMSIS2, 0);
break;
}
#endif

View File

@ -34,9 +34,9 @@ typedef void gThreadreturn;
typedef osPriority_t gThreadpriority;
#define MAX_SEMAPHORE_COUNT 65535UL
#define LOW_PRIORITY osPriorityLow
#define NORMAL_PRIORITY osPriorityNormal
#define HIGH_PRIORITY osPriorityHigh
#define gThreadpriorityLow osPriorityLow
#define gThreadpriorityNormal osPriorityNormal
#define gThreadpriorityHigh osPriorityHigh
typedef osSemaphoreId_t gfxSem;

View File

@ -29,9 +29,9 @@ typedef cyg_addrword_t gThreadpriority;
typedef cyg_handle_t gfxThreadHandle;
#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF
#define LOW_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
#define NORMAL_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
#define HIGH_PRIORITY 0
#define gThreadpriorityLow (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
#define gThreadpriorityNormal (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
#define gThreadpriorityHigh 0
#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(cyg_addrword_t param)

View File

@ -52,7 +52,7 @@ void _gosPostInit(void)
{
#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, NORMAL_PRIORITY, startUGFX_FreeRTOS, 0);
gfxThreadCreate(0, GFX_OS_UGFXMAIN_STACKSIZE, gThreadpriorityNormal, startUGFX_FreeRTOS, 0);
vTaskStartScheduler();
gfxHalt("Unable to start FreeRTOS scheduler. Out of memory?");
}

View File

@ -33,9 +33,9 @@ typedef void gThreadreturn;
typedef portBASE_TYPE gThreadpriority;
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY configMAX_PRIORITIES/2
#define HIGH_PRIORITY configMAX_PRIORITIES-1
#define gThreadpriorityLow 0
#define gThreadpriorityNormal configMAX_PRIORITIES/2
#define gThreadpriorityHigh configMAX_PRIORITIES-1
/* FreeRTOS will allocate the stack when creating the thread */
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1]

View File

@ -52,9 +52,9 @@ typedef pthread_mutex_t gfxMutex;
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0
#define HIGH_PRIORITY -10
#define gThreadpriorityLow 10
#define gThreadpriorityNormal 0
#define gThreadpriorityHigh -10
#if GFX_USE_POSIX_SEMAPHORES
typedef struct gfxSem {

View File

@ -44,9 +44,9 @@ typedef pthread_mutex_t gfxMutex;
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0
#define HIGH_PRIORITY -10
#define gThreadpriorityLow 10
#define gThreadpriorityNormal 0
#define gThreadpriorityHigh -10
typedef struct gfxSem {
pthread_mutex_t mtx;

View File

@ -17,9 +17,9 @@
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY 2
#define NORMAL_PRIORITY 3
#define HIGH_PRIORITY 4
#define gThreadpriorityLow 2
#define gThreadpriorityNormal 3
#define gThreadpriorityHigh 4
typedef int gTicks;
typedef int gDelay;

View File

@ -14,9 +14,9 @@ typedef uint32_t gThreadreturn;
typedef RAW_U8 gThreadpriority;
#define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
#define LOW_PRIORITY (CONFIG_RAW_PRIO_MAX-2)
#define NORMAL_PRIORITY (CONFIG_RAW_PRIO_MAX/2)
#define HIGH_PRIORITY 1
#define gThreadpriorityLow (CONFIG_RAW_PRIO_MAX-2)
#define gThreadpriorityNormal (CONFIG_RAW_PRIO_MAX/2)
#define gThreadpriorityHigh 1
typedef RAW_SEMAPHORE gfxSem;
typedef RAW_MUTEX gfxMutex;

View File

@ -38,9 +38,9 @@ typedef int gThreadpriority;
#define gDelayNone 0
#define gDelayForever INFINITE
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY THREAD_PRIORITY_BELOW_NORMAL
#define NORMAL_PRIORITY THREAD_PRIORITY_NORMAL
#define HIGH_PRIORITY THREAD_PRIORITY_ABOVE_NORMAL
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
typedef HANDLE gfxSem;
typedef HANDLE gfxMutex;

View File

@ -37,9 +37,9 @@ typedef int gThreadpriority;
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT 0x7FFF
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 2
#define gThreadpriorityLow 0
#define gThreadpriorityNormal 1
#define gThreadpriorityHigh 2
typedef struct {
gSemcount cnt;

View File

@ -33,9 +33,9 @@ typedef int gThreadpriority;
#define gDelayNone K_NO_WAIT
#define gDelayForever K_FOREVER
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY CONFIG_NUM_PREEMPT_PRIORITIES-1
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 0
#define gThreadpriorityLow CONFIG_NUM_PREEMPT_PRIORITIES-1
#define gThreadpriorityNormal 1
#define gThreadpriorityHigh 0
typedef struct k_sem gfxSem;

View File

@ -28,10 +28,10 @@
*/
/**
* @brief Defines the GTIMER thread priority
* @details Defaults to HIGH_PRIORITY
* @details Defaults to gThreadpriorityHigh
*/
#ifndef GTIMER_THREAD_PRIORITY
#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
#define GTIMER_THREAD_PRIORITY gThreadpriorityHigh
#endif
/**
* @brief Defines the size of the timer threads work area (stack+structures).