From 569f849c4fcafdd620d2e41f14ced1bc7c6ce0a7 Mon Sep 17 00:00:00 2001 From: wangzhuowei Date: Thu, 7 Sep 2023 13:39:59 +0800 Subject: [PATCH] feat: add SchedStatus --- lang/runtimex/sched.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lang/runtimex/sched.go b/lang/runtimex/sched.go index 8e1cd5d9..618a25bc 100644 --- a/lang/runtimex/sched.go +++ b/lang/runtimex/sched.go @@ -25,25 +25,29 @@ var ( //prunqField = pType.FieldByName("runq") ) -func MPreemptOff() { +func MPreemptOff() bool { g := getg() m := *((**_m)(unsafe.Pointer(g + mField.Offset()))) preemptoff := (*string)(unsafe.Pointer((uintptr)(unsafe.Pointer(m)) + mpreemptoffField.Offset())) if *preemptoff == "" { *preemptoff = "holding" + return true } + return false } -func MPreemptOn() { +func MPreemptOn() bool { g := getg() m := *((**_m)(unsafe.Pointer(g + mField.Offset()))) preemptoff := (*string)(unsafe.Pointer((uintptr)(unsafe.Pointer(m)) + mpreemptoffField.Offset())) if *preemptoff != "" { *preemptoff = "" + return true } + return false } -func schedlog() { +func SchedStatus() { g := getg() m := *((**_m)(unsafe.Pointer(g + mField.Offset()))) p := *((**_p)(unsafe.Pointer(uintptr(unsafe.Pointer(m)) + pField.Offset())))