File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22/*
33 * Syscall WCET slot — filled by the kernel when ULMK_CONFIG_SYSCALL_WCET=1.
44 *
5- * Lives in .user_bss so driver threads may read it without mem_map.
6- * After each syscall the kernel updates nr/delta/begin/end/blocked and
7- * increments seq.
5+ * g_ulmk_syscall_wcet[cpu] is the last sample on that CPU (debug / legacy).
6+ * For correct measurement when more than one thread runs on a CPU (IPC),
7+ * bind a private slot with ulmk_wcet_bind() — the kernel then also writes
8+ * that thread's samples there, without peer overwrite.
89 */
910
1011#ifndef ULMK_SYSCALL_WCET_H
1112#define ULMK_SYSCALL_WCET_H
1213
1314#include <stdint.h>
1415
15- #define ULMK_SYSCALL_WCET_MAGIC 0x57434554u /* 'WCET' */
16+ #define ULMK_SYSCALL_WCET_MAGIC 0x57434554u /* 'WCET' */
17+
18+ #define ULMK_SYSCALL_WCET_MAX_CPUS 8u
1619
1720struct ulmk_syscall_wcet_slot {
1821 uint32_t magic ;
@@ -30,6 +33,7 @@ struct ulmk_syscall_wcet_slot {
3033 uint32_t blocked ;
3134};
3235
33- extern volatile struct ulmk_syscall_wcet_slot g_ulmk_syscall_wcet ;
36+ extern volatile struct ulmk_syscall_wcet_slot
37+ g_ulmk_syscall_wcet [ULMK_SYSCALL_WCET_MAX_CPUS ];
3438
3539#endif /* ULMK_SYSCALL_WCET_H */
Original file line number Diff line number Diff line change 1111
1212struct ulmk_thread ;
1313
14+ uint32_t ulmk_kern_wcet_bind (uint32_t slot_ptr );
15+
1416#if ULMK_CONFIG_SYSCALL_WCET
1517void ulmk_syscall_wcet_account_reset (void );
1618uint32_t ulmk_syscall_wcet_blocked_cycles (void );
Original file line number Diff line number Diff line change 77 */
88
99#include <ulmk/syscall_wcet.h>
10+ #include <ulmk/microkernel.h>
1011#include <ulmk/config.h>
1112#include <ulmk_arch.h>
1213#include <kernel/include/ulmk_sched.h>
1314#include <kernel/include/ulmk_thread_internal.h>
1415
15- volatile struct ulmk_syscall_wcet_slot g_ulmk_syscall_wcet
16+ volatile struct ulmk_syscall_wcet_slot
17+ g_ulmk_syscall_wcet [ULMK_SYSCALL_WCET_MAX_CPUS ]
1618 __attribute__((section (".user_bss" )));
1719
1820#if ULMK_CONFIG_SYSCALL_WCET
@@ -56,4 +58,29 @@ void ulmk_syscall_wcet_block_end_th(struct ulmk_thread *th)
5658 t -> wcet_block_open = 0u ;
5759}
5860
61+ uint32_t ulmk_kern_wcet_bind (uint32_t slot_ptr )
62+ {
63+ ulmk_thread_t * cur = ulmk_sched_current ();
64+ volatile struct ulmk_syscall_wcet_slot * slot ;
65+
66+ if (!cur )
67+ return (uint32_t )(int32_t )ULMK_EINVAL ;
68+
69+ slot = (volatile struct ulmk_syscall_wcet_slot * )(uintptr_t )slot_ptr ;
70+ cur -> wcet_out = slot ;
71+ if (slot ) {
72+ slot -> magic = ULMK_SYSCALL_WCET_MAGIC ;
73+ slot -> seq = 0u ;
74+ }
75+ return (uint32_t )ULMK_OK ;
76+ }
77+
78+ #else /* !ULMK_CONFIG_SYSCALL_WCET */
79+
80+ uint32_t ulmk_kern_wcet_bind (uint32_t slot_ptr )
81+ {
82+ (void )slot_ptr ;
83+ return (uint32_t )(int32_t )ULMK_EINVAL ;
84+ }
85+
5986#endif /* ULMK_CONFIG_SYSCALL_WCET */
You can’t perform that action at this time.
0 commit comments