Skip to content

Commit

Permalink
feat: add SchedStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Sep 7, 2023
1 parent 92184d0 commit 569f849
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lang/runtimex/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Expand Down

0 comments on commit 569f849

Please sign in to comment.