Skip to content

Commit 7a8300d

Browse files
committed
Use updated Thread API
1 parent 3d5c2f9 commit 7a8300d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

source/client_a.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static uint32_t get_a_number()
4444
return (uvisor_ctx->number -= 500UL);
4545
}
4646

47-
static void box_async_runner(const void *)
47+
static void box_async_runner(void)
4848
{
4949
while (1) {
5050
uvisor_rpc_result_t result;
@@ -73,7 +73,7 @@ static void box_async_runner(const void *)
7373
}
7474
}
7575

76-
static void box_sync_runner(const void *)
76+
static void box_sync_runner(void)
7777
{
7878
while (1) {
7979
/* Synchronous access to the number. */
@@ -93,7 +93,11 @@ static void client_a_main(const void *)
9393
return;
9494
}
9595

96+
/* Create new threads. */
97+
/* Note: The stack must be at least 1kB since threads will use printf. */
9698
srand(uvisor_box_id_self());
97-
new Thread(box_sync_runner, NULL);
98-
new Thread(box_async_runner, NULL);
99+
Thread sync(osPriorityNormal, 1024, NULL);
100+
sync.start(box_sync_runner);
101+
Thread async(osPriorityNormal, 1024, NULL);
102+
async.start(box_async_runner);
99103
}

source/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static uint32_t get_a_number()
4646
return (number -= 400UL);
4747
}
4848

49-
static void main_async_runner(const void *)
49+
static void main_async_runner(void)
5050
{
5151
while (1) {
5252
uvisor_rpc_result_t result;
@@ -75,7 +75,7 @@ static void main_async_runner(const void *)
7575
}
7676
}
7777

78-
static void main_sync_runner(const void *)
78+
static void main_sync_runner(void)
7979
{
8080
while (1) {
8181
/* Synchronous access to the number. */
@@ -94,8 +94,11 @@ int main(void)
9494
led_green = LED_OFF;
9595

9696
/* Startup a few RPC runners. */
97-
Thread sync(main_sync_runner, NULL);
98-
Thread async(main_async_runner, NULL);
97+
/* Note: The stack must be at least 1kB since threads will use printf. */
98+
Thread sync(osPriorityNormal, 1024, NULL);
99+
sync.start(main_sync_runner);
100+
Thread async(osPriorityNormal, 1024, NULL);
101+
async.start(main_async_runner);
99102

100103
size_t count = 0;
101104

0 commit comments

Comments
 (0)