@@ -8,24 +8,11 @@ volatile bool serial_ready = false;
88static volatile uint64_t timestamp_exit = 0 ;
99static volatile uint64_t timestamp_enter = 0 ;
1010
11- static async_context_threadsafe_background_t asyncCtx ;
11+ static async_context_threadsafe_background_t async_ctx ;
1212
1313uint32_t do_some_work (void *param) {
1414 const auto value = static_cast <uint32_t *>(param);
1515 (*value)++;
16- // Log timestamp right before sem_release will happen
17- if (const auto worker = static_cast <async_when_pending_worker *>(
18- asyncCtx.core .when_pending_list )) {
19- Serial1.printf (" [INFO][%u][%llu] Pre-sem_release worker state:\n "
20- " address: %p\n "
21- " next: %p\n "
22- " do_work: %p\n "
23- " work_pending: %d\n "
24- " value: %d\n " ,
25- get_core_num (), to_us_since_boot (get_absolute_time ()),
26- worker, worker->next , worker->do_work , worker->work_pending ,
27- *value);
28- }
2916 return *value;
3017}
3118
@@ -54,7 +41,7 @@ void setup1() {
5441 }
5542 async_context_threadsafe_background_config_t cfg =
5643 async_context_threadsafe_background_default_config ();
57- operational = async_context_threadsafe_background_init (&asyncCtx , &cfg);
44+ operational = async_context_threadsafe_background_init (&async_ctx , &cfg);
5845 assert (operational);
5946 Serial1.printf (" C1 ready...\n " );
6047}
@@ -63,15 +50,31 @@ void loop() {
6350 static unsigned long c0_counter = 0 ;
6451 static uint32_t ref_counter = 0 ;
6552
66- if (c0_counter % 111 == 0 ) {
53+ if (c0_counter == 55 ) {
54+ timestamp_enter = to_us_since_boot (get_absolute_time ());
55+ const auto rc =
56+ async_context_execute_sync (&async_ctx.core , do_some_work, &ref_counter);
57+ assert (rc == ref_counter);
58+ timestamp_exit = to_us_since_boot (get_absolute_time ());
59+ Serial1.printf (" [Counter %d][Enter at: %llu][Exit at: %llu]\n " ,
60+ rc, timestamp_enter, timestamp_exit);
61+ } else if (c0_counter == 77 ) {
62+ timestamp_enter = to_us_since_boot (get_absolute_time ());
63+ const auto rc =
64+ async_context_execute_sync (&async_ctx.core , do_some_work, &ref_counter);
65+ assert (rc == ref_counter);
66+ timestamp_exit = to_us_since_boot (get_absolute_time ());
67+ Serial1.printf (" [Counter %d][Enter %llu] Exit %llu from boot\n " ,
68+ rc, timestamp_enter, timestamp_exit);
69+ } else if (c0_counter == 111 ) {
6770 timestamp_enter = to_us_since_boot (get_absolute_time ());
6871 const auto rc =
69- async_context_execute_sync (&asyncCtx .core , do_some_work, &ref_counter);
72+ async_context_execute_sync (&async_ctx .core , do_some_work, &ref_counter);
7073 assert (rc == ref_counter);
7174 timestamp_exit = to_us_since_boot (get_absolute_time ());
72- Serial1.printf (" [INFO][%u][%llu] value: %d; enter: %llu; exit: %llu\n " ,
73- get_core_num (), timestamp_exit, rc, timestamp_enter,
74- timestamp_exit) ;
75+ Serial1.printf (" Counter %d; Enter %llu, Exit %llu from boot \n " ,
76+ rc, timestamp_enter, timestamp_exit);
77+ c0_counter = 0 ;
7578 }
7679 c0_counter++;
7780 delay (1 );
0 commit comments