Skip to content

Commit

Permalink
Remove action_event_t member from the thread structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
At-EC committed Oct 19, 2024
1 parent a60a1a3 commit 873785d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions build_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
extern "C" {
#endif

#define ATOS_BUILD_TIME "2024-09-29,16:42"
#define ATOS_COMMIT_HEAD_ID "50e6e35a3e1ab0c51204ff418c1e8382c395a7ed"
#define ATOS_BUILD_TIME "2024-10-19,15:00"
#define ATOS_COMMIT_HEAD_ID "a60a1a349cce093dc6558368f70570484e2e3e4e"
#define ATOS_VERSION_MAJOR_NUMBER (1u)
#define ATOS_VERSION_MINOR_NUMBER (7u)
#define ATOS_VERSION_PATCH_NUMBER (4u)
#define ATOS_VERSION_PATCH_NUMBER (5u)

#define ATOS_VERSION_MAJOR_NUMBER_MASK (0x03FFu)
#define ATOS_VERSION_MAJOR_NUMBER_POS (22u)
Expand Down
5 changes: 1 addition & 4 deletions include/kernel/kstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ typedef struct {
/* The listen bits*/
u32_t listen;

/* The user value pointer, the user only can access it until it meets with the group setting so that it can be clean */
os_evt_val_t *pEvtVal;
} action_event_t;
} event_sch_t;

typedef struct {
/* A common struct head to link with other context */
Expand Down Expand Up @@ -250,8 +249,6 @@ typedef struct {

u32_t PSPStartAddr;

action_event_t event;

action_queue_t queue;

action_pool_t pool;
Expand Down
54 changes: 28 additions & 26 deletions kernel/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ static void _event_schedule(os_id_t id)

u32_t changed, any, edge, level, trigger = 0u;
event_context_t *pCurEvent = _event_object_contextGet(pEntryThread->schedule.hold);
os_evt_val_t *pEvtVal = pEntryThread->event.pEvtVal;
changed = pEvtVal->value ^ pCurEvent->value;
event_sch_t* pEvt_sche = (event_sch_t*)pEntryThread->schedule.pPendData;
if (!pEvt_sche) {
return;
}
changed = pEvt_sche->pEvtVal->value ^ pCurEvent->value;
if (changed) {
// Any position
any = pCurEvent->anyMask;
Expand Down Expand Up @@ -145,17 +148,13 @@ static void _event_schedule(os_id_t id)
// Triggered bits
trigger |= pCurEvent->triggered;

pEvtVal->value = pCurEvent->value;
u32_t report = trigger & pEntryThread->event.listen;
pEvt_sche->pEvtVal->value = pCurEvent->value;
u32_t report = trigger & pEvt_sche->listen;
if (report) {
pEvtVal->trigger = trigger;
pEvt_sche->pEvtVal->trigger = trigger;
pCurEvent->triggered &= ~report;
}

/* Auto clear user configuration */
pEntryThread->event.listen = 0u;
pEntryThread->event.pEvtVal = NULL;

pEntryThread->schedule.entry.result = 0;
}

Expand Down Expand Up @@ -296,13 +295,15 @@ static i32p_t _event_set_privilege_routine(arguments_t *pArgs)
list_iterator_init(&it, _event_list_blockingHeadGet(id));
thread_context_t *pCurThread = (thread_context_t *)list_iterator_next(&it);
while (pCurThread) {
report = trigger & pCurThread->event.listen;

event_sch_t* pEvt_sche = (event_sch_t*)pCurThread->schedule.pPendData;
if (!pEvt_sche) {
return _PCER;
}
report = trigger & pEvt_sche->listen;
if (report) {
reported |= report;
pCurThread->event.pEvtVal->trigger = trigger;
pCurThread->event.pEvtVal->value = val;

pEvt_sche->pEvtVal->trigger = trigger;
pEvt_sche->pEvtVal->value = val;
postcode = kernel_thread_entry_trigger(pCurThread, 0, _event_schedule);
PC_IF(postcode, PC_ERROR)
{
Expand Down Expand Up @@ -330,19 +331,16 @@ static i32p_t _event_wait_privilege_routine(arguments_t *pArgs)
ENTER_CRITICAL_SECTION();

os_id_t id = (os_id_t)pArgs[0].u32_val;
os_evt_val_t *pEvtData = (os_evt_val_t *)pArgs[1].pv_val;
u32_t listen = (u32_t)pArgs[2].u32_val;
u32_t timeout_ms = (u32_t)pArgs[3].u32_val;
event_sch_t *pEvt_sch = (event_sch_t *)pArgs[1].pv_val;
u32_t timeout_ms = (u32_t)pArgs[2].u32_val;
i32p_t postcode = 0;

thread_context_t *pCurThread = kernel_thread_runContextGet();
event_context_t *pCurEvent = _event_object_contextGet(id);
pCurThread->event.listen = listen;
pCurThread->event.pEvtVal = pEvtData;
u32_t val = pEvtData->value;
os_evt_val_t *pEvtData = pEvt_sch->pEvtVal;
u32_t changed, any, edge, level, trigger = 0u;

changed = val ^ pCurEvent->value;
changed = pEvtData->value ^ pCurEvent->value;
if (changed) {
// Any position
any = pCurEvent->anyMask;
Expand Down Expand Up @@ -374,8 +372,8 @@ static i32p_t _event_wait_privilege_routine(arguments_t *pArgs)
// Triggered bits
trigger |= pCurEvent->triggered;

pEvtData->value = val;
u32_t report = trigger & pCurThread->event.listen;
pEvtData->value = pCurEvent->value;
u32_t report = trigger & pEvt_sch->listen;
if (report) {
pEvtData->trigger = trigger;
pCurEvent->triggered &= ~report;
Expand All @@ -384,6 +382,7 @@ static i32p_t _event_wait_privilege_routine(arguments_t *pArgs)
return postcode;
}

pCurThread->schedule.pPendData = (void*)pEvt_sch;
postcode = kernel_thread_exit_trigger(pCurThread, id, _event_list_blockingHeadGet(id), timeout_ms);
PC_IF(postcode, PC_PASS)
{
Expand Down Expand Up @@ -524,11 +523,14 @@ i32p_t _impl_event_wait(os_id_t id, os_evt_val_t *pEvtData, u32_t listen_mask, u
return _PCER;
}

event_sch_t evt_sch = {
.listen = listen_mask,
.pEvtVal = pEvtData,
};
arguments_t arguments[] = {
[0] = {.u32_val = (u32_t)id},
[1] = {.pv_val = (void *)pEvtData},
[2] = {.u32_val = (u32_t)listen_mask},
[3] = {.u32_val = (u32_t)timeout_ms},
[1] = {.pv_val = (void *)&evt_sch},
[2] = {.u32_val = (u32_t)timeout_ms},
};

i32p_t postcode = kernel_privilege_invoke((const void *)_event_wait_privilege_routine, arguments);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "At-RTOS",
"homepage": "https://github.com/At-EC/At-RTOS",
"version": "1.7.4",
"timestamp": "2024-09-29,16:42",
"commit_id": "43b81cfccb4b59101d9a4656b5157cfc4a805e3b"
"version": "1.7.5",
"timestamp": "2024-10-19,15:00",
"commit_id": "50e6e35a3e1ab0c51204ff418c1e8382c395a7ed"
}

0 comments on commit 873785d

Please sign in to comment.