| 1493 | } |
| 1494 | |
| 1495 | int stack_pages_gc(thread* th) { |
| 1496 | if (!th || th->vcpu != CURRENT->vcpu) |
| 1497 | LOG_ERROR_RETURN(EINVAL, -1, "target thread ` must be run on CURRENT vCPU", th); |
| 1498 | if (th->state == RUNNING) { |
| 1499 | auto next = AtomicRunQ().goto_next().to; |
| 1500 | switch_context_defer(th, next, do_stack_pages_gc, th); |
| 1501 | } else { |
| 1502 | do_stack_pages_gc(th); |
| 1503 | } |
| 1504 | return 0; |
| 1505 | } |
| 1506 | |
| 1507 | template<typename T, typename PT = T*> inline |
| 1508 | T* indirect_lock(volatile PT* ppt, T* end) |