Skip to content

Commit fa20cac

Browse files
committed
usched: switch to slist.h
1 parent 5ad3d43 commit fa20cac

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/exec_context.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
#include "toywasm_config.h"
99

10-
#include "list.h"
1110
#include "options.h"
1211
#include "platform.h"
1312
#include "report.h"
13+
#include "slist.h"
1414
#include "vec.h"
1515

1616
struct val;
@@ -279,7 +279,7 @@ struct exec_context {
279279
#if defined(TOYWASM_USE_USER_SCHED)
280280
/* scheduler */
281281
struct sched *sched;
282-
LIST_ENTRY(struct exec_context) rq;
282+
SLIST_ENTRY(struct exec_context) rq;
283283
#endif
284284

285285
/* Trap */

lib/usched.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ sched_enqueue(struct sched *sched, struct exec_context *ctx)
3939
{
4040
xlog_trace("%s: enqueueing ctx %p", __func__, (void *)ctx);
4141
assert(sched == ctx->sched);
42-
LIST_INSERT_TAIL(&sched->runq, ctx, rq);
42+
SLIST_INSERT_TAIL(&sched->runq, ctx, rq);
4343
}
4444

4545
#define RR_INTERVAL_MS 100
@@ -50,9 +50,9 @@ sched_run(struct sched *sched, struct exec_context *caller)
5050
struct runq *q = &sched->runq;
5151
struct exec_context *ctx;
5252

53-
while ((ctx = LIST_FIRST(q)) != NULL) {
53+
while ((ctx = SLIST_FIRST(q)) != NULL) {
5454
int ret;
55-
LIST_REMOVE(q, ctx, rq);
55+
SLIST_REMOVE_HEAD(q, ctx, rq);
5656
xlog_trace("%s: running ctx %p", __func__, (void *)ctx);
5757
ret = abstime_from_reltime_ms(
5858
CLOCK_MONOTONIC, &sched->next_resched, RR_INTERVAL_MS);
@@ -71,7 +71,7 @@ sched_run(struct sched *sched, struct exec_context *caller)
7171
if (IS_RESTARTABLE(ret) && ret != ETOYWASMUSERINTERRUPT) {
7272
xlog_trace("%s: re-enqueueing ctx %p", __func__,
7373
(void *)ctx);
74-
LIST_INSERT_TAIL(q, ctx, rq);
74+
SLIST_INSERT_TAIL(q, ctx, rq);
7575
continue;
7676
}
7777
xlog_trace("%s: finishing ctx %p", __func__, (void *)ctx);
@@ -87,7 +87,7 @@ sched_run(struct sched *sched, struct exec_context *caller)
8787
void
8888
sched_init(struct sched *sched)
8989
{
90-
LIST_HEAD_INIT(&sched->runq);
90+
SLIST_HEAD_INIT(&sched->runq);
9191
}
9292

9393
void
@@ -102,7 +102,7 @@ sched_need_resched(struct sched *sched)
102102
int ret;
103103

104104
/* if we are the only thread, no point to resched. */
105-
if (LIST_FIRST(&sched->runq) == NULL) {
105+
if (SLIST_FIRST(&sched->runq) == NULL) {
106106
return false;
107107
}
108108

lib/usched.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include <stdbool.h>
22
#include <time.h>
33

4-
#include "list.h"
54
#include "platform.h"
5+
#include "slist.h"
66

77
struct exec_context;
88

99
struct sched {
10-
LIST_HEAD_NAMED(struct exec_context, runq) runq;
10+
SLIST_HEAD_NAMED(struct exec_context, runq) runq;
1111
struct timespec next_resched;
1212
};
1313

0 commit comments

Comments
 (0)