Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

curproc(9) [netbsd man page]

CURPROC(9)						   BSD Kernel Developer's Manual						CURPROC(9)

NAME
curproc, curcpu, curlwp -- current process, processor, and LWP SYNOPSIS
#include <sys/proc.h> struct cpu_info * curcpu(void); struct proc * curproc(void); struct lwp * curlwp(void); DESCRIPTION
The following macros can be used to retrieve the current processor, process, and light-weight process (LWP), respectively: 1. The machine-dependent curcpu() macro returns a pointer to a cpu_info structure containing information of the CPU that this thread is running on. 2. The machine-independent curproc() macro refers to a pointer to the process currently running on this CPU. 3. The curlwp() macro expands to a pointer to lwp structure, containing information about the current LWP. This macro is machine- independent, but machine-dependent <machine/cpu.h> may redefine it. SEE ALSO
cpu_number(9), proc_find(9) BSD
July 1, 2010 BSD

Check Out this Related Man Page

CPU_SWITCHTO(9) 					   BSD Kernel Developer's Manual					   CPU_SWITCHTO(9)

NAME
cpu_switchto -- machine-dependent LWP context switching interface SYNOPSIS
#include <sys/cpu.h> lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning); DESCRIPTION
The cpu_switchto() function saves the context of the LWP which is currently running on the processor, and restores the context of the LWP specified by newlwp. Remarks: 1. cpu_switchto() does not switch address spaces. 2. cpu_switchto() sets curlwp(9) to newlwp. If the architecture does non-interlocked adaptive mutex release, cpu_switchto() does an equivalent of membar_producer(3), before and after the modification of curlwp(9). 3. cpu_switchto() should be called at IPL_SCHED. When the function returns, the caller should lower the priority level as soon as possible. 4. cpu_switchto() might be called with spin mutexes held. The function takes the following arguments. oldlwp Specify the LWP from which the switch is going to be made, i.e., the calling LWP. If it was NULL, the context of the LWP currently running on this processor is not saved. newlwp Specify the LWP to which to switch. It must not be NULL. returning Only meaningful if the architecture implements fast software interrupts. If true, it indicates that oldlwp is a soft interrupt LWP that is blocking. It is a good indication that any kind of address space or user activity can be completely ignored. For example: ras_lookup(9), cache flushes, TLB wirings, adjusting lazy FPU state. All that is required is to restore the register state and stack, and return to the interrupted LWP. RETURN VALUES
The cpu_switchto() function does not return until another LWP calls cpu_switchto(). It returns the oldlwp argument of the cpu_switchto() which is called to switch back to our LWP. It is either a LWP which called cpu_switchto() to switch to us or NULL in case the LWP was exit- ing. SEE ALSO
membar_producer(3), swapcontext(3), intro(9), mutex(9), spl(9) BSD
June 2, 2011 BSD
Man Page