Go to the documentation of this file.
137 pri_aux.i32[1] = (
INT32) level;
156 ms = ms * (
unsigned int) G_TICKS_PER_MSECOND;
157 seconds = seconds * (
unsigned int) G_TICKS_PER_MSECOND * 1000;
158 minutes = minutes * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60;
159 hours = hours * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60 * 60;
182 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
184 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
200 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
202 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
218 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
220 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
236 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
238 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
259 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
260 ms = ms * (
unsigned int) G_TICKS_PER_MSECOND;
261 seconds = seconds * (
unsigned int) G_TICKS_PER_MSECOND * 1000;
262 minutes = minutes * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60;
263 hours = hours * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60 * 60;
266 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
287 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
288 ms = ms * (
unsigned int) G_TICKS_PER_MSECOND;
289 seconds = seconds * (
unsigned int) G_TICKS_PER_MSECOND * 1000;
290 minutes = minutes * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60;
291 hours = hours * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60 * 60;
294 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
316 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
317 ms = ms * (
unsigned int) G_TICKS_PER_MSECOND;
318 seconds = seconds * (
unsigned int) G_TICKS_PER_MSECOND * 1000;
319 minutes = minutes * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60;
320 hours = hours * (
unsigned int) G_TICKS_PER_MSECOND * 1000 * 60 * 60;
327 case G_TCBType_PERIODIC:
332 if (ticks == (
INT64) 0){
342 pevent->ECBValue.i64 = (
INT64) ticks;
343 pevent->ECBType = (
INT32) G_ECBType_PERIODIC;
354 G_DEBUG_WHILEFOREVER;
374 if ((abort_when_deadline != G_TRUE) && (abort_when_deadline != G_FALSE))
return G_FALSE;
375 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
377 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
396 unsigned int StkSize)
399 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
415 if (
G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
416 return ((
void *) ptcb);
435 ms = ms * (
INT32) G_TICKS_PER_MSECOND;
436 seconds = seconds * (
INT32) G_TICKS_PER_MSECOND * (
INT32) 1000;
437 minutes = minutes * (
INT32) G_TICKS_PER_MSECOND * (
INT32) 1000 * (
INT32) 60;
462 GRTOS_USER_CRITICAL_SECTION_GET;
467 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
468 if ((
TCB_IsValid(ptcbcurrent) != G_TRUE) && (ptcbcurrent == (
struct gs_tcb *) 0)) G_DEBUG_WHILEFOREVER;
469 if (
ECB_IsValid(pevent) != G_TRUE) G_DEBUG_WHILEFOREVER;
472 pevent->ECBValue.i64 =
GRTOS_now + ticks;
474 pevent->ECBType = (
INT32) G_ECBType_OSTimeDly;
501 GRTOS_USER_CRITICAL_SECTION_GET;
503 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
518 GRTOS_USER_CRITICAL_SECTION_GET;
536 GRTOS_USER_CRITICAL_SECTION_GET;
538 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
552 int return_value = G_FALSE;
553 GRTOS_USER_CRITICAL_SECTION_GET;
554 if (GRTOS_TASK_STATE_WAITING(ptcb)) {
557 return_value = G_TRUE;
560 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
585 GRTOS_USER_CRITICAL_SECTION_GET;
588 pscb->SCBPriority = Priority;
589 pscb->SCBType = Type;
590 pscb->SCB_TaskCode = Signal_Code;
591 pscb->SCB_TaskArg = (
void *) Signal_Arg;
592 pscb->SCB_NextSCBAPSL = (
struct gs_scb *) 0;
593 pscb->SCB_AssocXCB = pxcb;
599 pscb->SCBState = G_SCBState_IN_KCB;
605 pscb->SCBState = G_SCBState_IN_ECB;
609 case G_SCBType_TCB_ABORTED:
611 pscb->SCBState = G_SCBState_IN_TCB;
617 pscb->SCBState = G_SCBState_IN_RCB;
630 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
644 GRTOS_USER_CRITICAL_SECTION_GET;
645 void *pxcb = (
void *) pscb->SCB_AssocXCB;
650 while (result == G_TRUE && pscb_pending != (
struct gs_scb *) 0)
654 pscb_pending = pscb->SCB_NextSCBAPSL;
657 if (pscb->SCB_NextSCBAPSL == (
struct gs_scb *) 0)
659 switch (pscb->SCBType){
664 pscb->SCBState = G_SCBState_UNLINKED;
670 pscb->SCBState = G_SCBState_UNLINKED;
676 pscb->SCBState = G_SCBState_UNLINKED;
682 pscb->SCBState = G_SCBState_UNLINKED;
697 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
738 GRTOS_USER_CRITICAL_SECTION_GET;
739 status = GRTOS_CMD_IRQ_RQS;
740 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
754 GRTOS_USER_CRITICAL_SECTION_GET;
757 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
773 GRTOS_USER_CRITICAL_SECTION_GET;
776 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
788 GRTOS_USER_CRITICAL_SECTION_GET;
791 GRTOS_CMD_CRITICAL_SECTION_RELEASE;
809 return_time.tm_year = (int) division.quot;
811 return_time.tm_day = (int) division.quot;
813 return_time.tm_hour = (int) division.quot;
815 return_time.tm_min = (int) division.quot;
816 division = lldiv((
INT64) division.rem, (
INT64)(G_TICKS_PER_MSECOND)*(
INT64)1000);
817 return_time.tm_sec = (int) division.quot;
818 return_time.tm_msec = (
int) ((int)division.rem/(
int) G_TICKS_PER_MSECOND);
831 GS_TCB *ptcb = pevent->ECB_AssocTCB;;
834 switch (pevent->ECBType)
836 case G_ECBType_OSTimeDly:
848 G_DEBUG_WHILEFOREVER;
852 case G_ECBType_PERIODIC:
859 pevent->ECBValue.i64 = (
INT64) pevent->ECBValue.i64 + ptcb->TCBPeriod;
864 case G_ECBType_TIMEOUT_SEM_WAITING:
869 case G_ECBType_TIMEOUT_SEM_GRANTED:
873 case G_ECBType_MESSAGE_SEND_WAIT:
877 case G_ECBType_MESSAGE_CONSUME_WAIT:
881 case G_ECBType_LASTEST_TIME:
883 G_DEBUG_WHILEFOREVER;
886 G_DEBUG_WHILEFOREVER;
898 switch (pevent->ECBType)
900 case G_ECBType_SEM_GRANTED:
901 case G_ECBType_TIMEOUT_SEM_GRANTED:
905 case G_ECBType_SEM_WAITING:
906 case G_ECBType_TIMEOUT_SEM_WAITING:
910 case G_ECBType_QUEUE_CONSUME:
926 fprintf(stderr,
"[ MESSAGE ] FROZEN REACHED . Proc: %d\n", GRTOS_CMD_PRC_ID);
INT32 gk_timeout_ECB_MQ_send(GS_ECB *peventime)
This function is called from the timed IRQ when a send timeout G_ECBType_MESSAGE_SEND_WAIT happens.
INT32 ECB_IsValid(GS_ECB *pevent)
Returns G_TRUE is pointer points to ECB.
INT32 gu_TASK_Sleep(INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Sleeps the current task the interval specified.
GS_TCB* gk_CreateTask(void *TaskCode, void *p_arg, void *StkBotton, unsigned int StkSize, unsigned int TCBType, INT64 TCBReadyPriority, INT64 TCBRunPriority, INT64 TCBDeadline, INT64 TCBPeriod, GS_LCB *TCB_RDY_LCB_Index, int TCB_Abort_w_Deadline, INT64 TCBInherPriority, int TCB_INTNumber)
Kernel Function: creates a new task initializing TCB features.
INT32 gk_timeout_ECB_MQ_consume(GS_ECB *peventime)
This function is called from the timed IRQ when a consume timeout G_ECBType_MESSAGE_CONSUME_WAIT happ...
INT32 gu_TASK_SUSPEND(GS_TCB *ptcb)
Change to waiting the state of a task.
INT32 gu_SetTaskType(struct gs_tcb *ptcb, unsigned int type)
Set the type of a task.
INT32 gk_timeout_ECB_SEM_post(GS_ECB *peventime)
Time routine for event G_ECBType_TIMEOUT_SEM_GRANTED. It is called from the time interrupt ISR.
INT32 gk_TCBASL_Link(GS_TCB *ptcb, GS_SCB *psignal)
Links SCB to TCB Associated Signal List.
void gk_KERNEL_TASK_SUSPEND(GS_TCB *ptcb)
Suspends the execution of the task pointed by ptcb.
INT32 gk_TCB_Unlink(GS_TCB *ptcb)
Unlinks the TCB according to the list it is linked.
volatile INT64 G_TASK_PRIORITY_DEFAULT
INT32 gu_get_irq_status(void)
Return the status of the system IRQs.
INT32 gk_TCBAEL_Link(GS_ECB *pevent, GS_TCB *ptcb)
Links an ECB to the associated ECB list of TCB.
INT32 gu_SetTaskAbortwhenDeadline(struct gs_tcb *ptcb, unsigned int abort_when_deadline)
Set if task should be aborted when misses a deadline.
INT32 gu_Set_Default_Task_List(GS_LCB *list)
Set the default list number for task created afterwards.
INT32 gu_TASK_Kill(GS_TCB *ptcb)
The task is eliminated and all the structures involved are return to the free lists.
struct gs_lcb* TCB_RDY_LCB_Index
pointer to the ready list that should be inserted
unsigned long long gt_time
INT32 gu_TASK_IS_BLOCKED(GS_TCB *ptcb)
Return G_TRUE if task is waiting for a resource, G_FALSE otherwise.
OPTIMEZE_CODE(3)
Creates a TCB and returns its pointer Returns a pointer to a Free TCB, NULL if it is not a TCB availa...
volatile GS_LCB* G_TASK_LCB_DEFAULT
GRTOS_now({ \ TIMEPRIORITY value64 \ do { \ value64.i32[1] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_TM_CNT_HGH) \ value64.i32[0] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_SMP) \ } while(0) \ value64.i64 \ })
GRTOS_now Return the current system time.
void gk_ECBASL_Link(GS_ECB *pevent, GS_SCB *psignal)
Links a SCB to the ECB Associated Signal List.
INT32 gk_RCBASL_Link(G_RCB *presource, GS_SCB *psignal)
Links a signal SCB to the resource RCB Associated Signal List.
INT32 gu_Set_Default_Task_Type(unsigned int type)
gu_Set_Default_Task_Type(unsigned int type) Set the default type of the task created.
INT32 gk_TCBAEL_Unlink(GS_ECB *pevent)
Unlinks the ECB from the associated TCB.
INT32 gu_TASK_RESUME(GS_TCB *ptcb)
Resume a task that it is in waiting state.
gt_time gu_Convert_Time(INT32 days, INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Convert days,hours, minutes, seconds and miliseconds to system time unit.
INT32 gk_KCBASL_Unlink(GS_SCB *psignal)
Unlinks a SCG from the Associated Signal list of KCB.
GS_SCB* gk_SCB_GetFree(void)
Unlinks a SCB from free list and return its pointer.
void gk_KERNEL_TASK_SUSPEND_CURRENT(void)
Suspends the execution of the current task and switch to Highest Priority Task.
gt_time gu_get_mutex_time(void)
Return the time the mutex is granted in system time units.
void gu_Set_Default_Task_Period(INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Set the default periodo for task created afterwards.
INT32 gu_StartTaskwithOffset(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Activates the execution of a task. An offset can be configured.
GS_LCB List Control Block.
INT32 gu_SetTaskReadyPriority(struct gs_tcb *ptcb, long long priority)
Set the ready priority of a task.
INT32 gk_TCBWL_Link(GS_TCB *ptcb, unsigned int state)
Links a TCB in the waiting list.
gs_tcb Task Control Block (TCB) structure
GS_SCB Signal Control Block structure.
INT32 gk_ECBASL_Unlink(GS_ECB *pevent, GS_SCB *psignal)
Unlinks a signal SCB from the ECB Associated Signal List of and event.
INT32 gk_SEM_granted_kill(GS_ECB *pevent1)
Removes the ECBs from a the granted list of a semaphore resource.
void gk_TIME_CALLBACK(GS_ECB *pevent)
This function is called when a time event happened. It has to resolve according the event type.
INT32 gk_RCBASL_Unlink(G_RCB *presource, GS_SCB *psignal)
Unlinks a SCB of a signal from the RCB Associated Signal List of a resource.
INT32 gk_TCBWL_Unlink(GS_TCB *ptcb)
Unlinks the TCB from the waiting list.
volatile INT64 G_TASK_PERIOD_DEFAULT
INT32 gu_SetTaskDeadline(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Set the deadline of the task for the next invocation.
INT32 gk_QUEUE_granted_kill(GS_ECB *pevent)
GRTOS_CMD_MTX_TM_GET({ \ TIMEPRIORITY value64 \ do { \ value64.i32[1] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_SYS_MUTEX_TIME_HGH) \ value64.i32[0] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_SMP) \ } while(0) \ value64.i64 \ })
GRTOS_CMD_MTX_TM_GET Return the time the mutex is granted in system time units.
Definition of GRTOS controller address.
INT64 TCBDeadline
Deadline of the task.
INT32 gk_TASK_IS_BLOCKED(GS_TCB *ptcb)
Returns G_TRUE when TCB is blocked waiting for a resource.
INT32 gk_SCBAPSL_UnLink(GS_SCB *pscb_root, GS_SCB *pscb_pending)
Unlinks a pending signal from the root signal.
union timepriority TIMEPRIORITY
volatile INT32 G_TASK_TYPE_DEFAULT
INT32 gk_TCBASL_Unlink(GS_TCB *ptcb, GS_SCB *psignal)
Unlinks SCB from a TCB Associated Signal List.
INT32 gu_SetTaskRunPriority(struct gs_tcb *ptcb, long long priority)
Set the run priority of a task.
gt_tm gu_Clock(gt_time ticks)
Convert to gt_tm structure a time in gt_time format (time in system time units)
INT32 gk_ECBTL_Link(GS_ECB *pevent)
Links the ECB from the Time Event List.
INT32 gu_SetTaskPeriod(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Set the task period for the next invocation.
INT32 gu_TASK_Sleep_Time(gt_time ticks)
Set event to sleep the current task for a certain number of clock ticks.
INT32 gk_timeout_ECB_SEM_wait(GS_ECB *peventime)
Time routine for event G_ECBType_TIMEOUT_SEM_WAITING. It is called from the time interrupt ISR.
INT32 gu_Get_Default_Task_List(void)
Return the current default list number.
GS_TCB* gk_PCB_GetCurrentTCB(void)
Returns the task that the current processor was executing.
INT32 gu_SetTaskList(struct gs_tcb *ptcb, struct gs_lcb *plcb)
Set the list of a task.
INT64 TCBReadyPriority
Priority of the Task when Ready.
void gu_Set_Default_Task_Priority(INT32 level, INT32 priority)
Set the default priority for task created afterwards. Priority is assigned with an INT32 level and an...
INT32 gk_TCBRDYL_Link(GS_TCB *ptcb)
Links the TCB in the Ready Task List sorted by its priority.
void gk_FROZEN_CALLBACK(void)
This function is called when a frozzen event happened.
int TCB_Abort_w_Deadline
True if task should be aborted when deadline, false otherwise.
INT32 gk_KCBASL_Link(GS_SCB *psignal)
Links a SCG to the Associated Signal list of KCB.
INT32 gk_TASK_Kill(GS_TCB *ptcb)
Destroys a task and return the data structure to the TCB free list.
gt_time gu_get_frozen_threshold(void)
Returns the value in the frozen threshold register (R_FRZ_TM_THR)
INT32 gu_Get_Default_Task_Type(void)
Return the default type assigned to new tasks.
INT32 gk_SEM_waiting_kill(GS_ECB *pevent1)
Removes the ECBs from a the waiting list of a semaphore resource.
GEmRTOS CORE definitions.
unsigned int TCBType
TYPE of the task.
INT32 gk_ECBFL_Link(GS_ECB *pevent)
Link ECB to Free List. Removes the signals from ECB.
void* gu_GetTask(void *TaskCode, void *p_arg, void *StkBotton, unsigned int StkSize)
Return a pointer to a TCB for a new task.
GS_SCB* gu_signal_create(INT32 Type, INT32 Priority, void *pxcb, void *Signal_Code, void *Signal_Arg)
Creates an associated SCB to a structure according to the Type.
struct gs_scb* SCB_NextSCBAPSL
Pointer to the next pending SCB lined.
INT64 TCBPeriod
Period of the task.
GS_ECB* gk_ECB_GetFree(void)
Returns a pointer to a Free ECB, NULL if there is not ECB available.
INT64 TCBRunPriority
Priority when it is executed.
INT32 TCB_IsValid(GS_TCB *ptcb)
gt_time gu_get_now(void)
Return the system time in system time units.
GRTOS_CMD_FRZ_TM_THR_GET({ \ TIMEPRIORITY value64 \ value64.i32[1] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_FRZ_THR_HGH) \ value64.i32[0] = (unsigned) IORD(GRTOS_DRIVER_GRTOS_BASE, ADDR_SMP) \ value64.i64 \ })
GRTOS_CMD_FRZ_TM_THR_GET Returns the value of the Frozen Time Threshold (R_FRZ_TM_THR) register of th...
INT32 gk_TASK_RELEASE(GS_TCB *ptcb)
Release a new invocation of the task. Preserves the Associated signal list. If task is not completed,...
INT32 gk_SCBFL_Link(GS_SCB *psignal)
Links a SCB to the Free List.
void gk_RESOURCE_ECB_KILL_CALLBACK(GS_ECB *pevent)
This function is called when a resource event is kill. It has to resolve according the event type.
INT32 gu_signal_destroy(GS_SCB *pscb)
Unlink the signal associated to a control block.