Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6498

Judge whether the current process is running when SMP is turned on

$
0
0

I found that there is a function called task_running in the kernel, and its judgment logic is as follows

static inline int task_current(struct rq *rq, struct task_struct *p){    return rq->curr == p;}static inline int task_running(struct rq *rq, struct task_struct *p){#ifdef CONFIG_SMP    return p->on_cpu;#else    return task_current(rq, p);#endif}

Is there any difference between rq->curr and p->on_cpu? I think they both mean that the process is being scheduled by the current cpu. Why separate judgments are required under SMP


Viewing all articles
Browse latest Browse all 6498

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>