Simple C Language Question

Jeremy Fowler jfowler at westrope.com
Tue Nov 19 15:59:10 CST 2002


Actually, current is a macro for the get_current() function that returns a
pointer to task_struct, the Linux task table.  It's defined in
include/asm/current.h and looks like this:

#ifndef _I386_CURRENT_H
#define _I386_CURRENT_H

struct task_struct;

static inline struct task_struct * get_current(void)
{
	struct task_struct *current;
	__asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
	return current;
 }

#define current get_current()

#endif /* !(_I386_CURRENT_H) */

You can read more about the task table here:
http://www.cs.columbia.edu/~ljtang/s4118/Task_Table.htm

> -----Original Message-----
> From: owner-kclug at marauder.illiana.net
> [mailto:owner-kclug at marauder.illiana.net]On Behalf Of Scott Bowling
> Sent: Monday, November 18, 2002 10:31 PM
> To: Kansas City Linux Users Group Mailing List
> Subject: Simple C Language Question
>
>
> Sorry if this is off topic but I figured it would be a simple question to
> answer.  My justification is because I have had the darnedest time trying to
> find a google answer
>
> I am fairly new to C Language and have picked up a few books.  I'm also
> using plenty of examples to do with what I'd like to do.  However there is
> one thing I cannot find an answer for.  I've seen source code that use the
> "current" structure.  For example, current->pid returns the current PID.
>
> I cannot find where this is defined anywhere.  I'd like to know what all the
> possible values I can call with this.
>
> If anyone can recommend a good C site, I'd love it.  I've current got "The
> Programming Language" 2nd Edition as my starting point.
>
> Thanks in advanced.
>
> Scott
>
>
>




More information about the Kclug mailing list