Skip to content

Commit f717100

Browse files
committed
rt: Start tasks, ports and scheds at 1, assert when we see 0. Closes #2321
1 parent 1db88e7 commit f717100

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/rt/rust_kernel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
rust_kernel::rust_kernel(rust_env *env) :
1616
_region(env, true),
1717
_log(NULL),
18-
max_task_id(0),
19-
max_port_id(0),
18+
max_task_id(1),
19+
max_port_id(1),
2020
rval(0),
21-
max_sched_id(0),
21+
max_sched_id(1),
2222
sched_reaper(this),
2323
osmain_driver(NULL),
2424
non_weak_tasks(0),
@@ -116,6 +116,7 @@ rust_kernel::get_scheduler_by_id(rust_sched_id id) {
116116

117117
rust_scheduler *
118118
rust_kernel::get_scheduler_by_id_nolock(rust_sched_id id) {
119+
assert(id != 0 && "invalid scheduler id");
119120
sched_lock.must_have_lock();
120121
sched_map::iterator iter = sched_table.find(id);
121122
if (iter != sched_table.end()) {
@@ -250,6 +251,7 @@ rust_kernel::release_port_id(rust_port_id id) {
250251

251252
rust_port *
252253
rust_kernel::get_port_by_id(rust_port_id id) {
254+
assert(id != 0 && "invalid port id");
253255
scoped_lock with(port_lock);
254256
rust_port *port = NULL;
255257
// get leaves port unchanged if not found.

0 commit comments

Comments
 (0)