Take the 2-minute tour ×

I am now looking for a piece of source code which treats about kernel preemption in FreeBSD.

In Linux kernel, there is a c-source file called "sched.c" in which set_current_state() macro is used to set the state of process (TASK_RUNNING, TASK_INTERRUPTIBLE or whatever). Those macros are defined in "sched.h". Could you tell me the corresponding source file(s) (which has the definition of those macros if they exist in FreeBSD) in FreeBSD kernel source tree?

share|improve this question
add comment

1 Answer

Relevant files are src/sys/kern/sched_4bsd.c (4BSD scheduler) and src/sys/kern/sched_ule.c (ULE scheduler). But there are no TASK_* defines or set_current_state() macro, since FreeBSD and Linux use different schedulers.

You may need to read one of them (i recommend 4bsd, since it's simpler) to find what you are interested in.

BTW, there was a project to port Linux' BFS scheduler, the code is there http://rudot.blog.com/. You might find it useful.

share|improve this answer
Hi, thank you for your info and sorry for late reply. BFS project is also very interesting to me. –  akry Jan 23 '12 at 9:49
add comment

Your Answer


