Simple C Language Question

SABowling at dstsystems.com SABowling at dstsystems.com
Tue Nov 19 20:02:56 CST 2002


Jeremy,

Thanks for the information.  I am using the linux/sched.h so it should be
all good.  I suppose if I would have removed that include from the example
I started with it would have enlightened me as to where the current macro
came from.

That link you sent was exactly what I was looking for.

Scott

--------------------------------------------------------------------------------

Scott Bowling
Analyst Programmer
DST Systems
816.435.4447
SABowling at dstsystems.com

                                                                                        
                    "Jeremy                                                             
                    Fowler"              To:     <SABowling at dstsystems.com>             
                    <jfowler at westr       cc:     "Kansas City Linux Users Group Mailing 
                    ope.com>              List" <kclug at kclug.org>                       
                                         Subject:     RE: Simple C Language Question    
                    11/19/2002                                                          
                    01:09 PM                                                            
                                                                                        
                                                                                        

Your right, kernel modules are different. You probably should use the
current->pid when building kernel modules. I believe in most
implementations,
getpid just returns current->pid anyway. So the extra overhead of adding a
system call to the stack is undesired when you can just use current->pid.

Something I left out before, don't include asm/current.h directly, since
it's
arch specific. Instead use linux/sched.h which will use the correct
current.h
for the appropriate hardware or whatever the BSD counterpart is.

> -----Original Message-----
> From: owner-kclug at marauder.illiana.net
> [mailto:owner-kclug at marauder.illiana.net]On Behalf Of
> SABowling at dstsystems.com
> Sent: Tuesday, November 19, 2002 11:26 AM
> To: Jeremy Fowler
> Cc: Kansas City Linux Users Group Mailing List
> Subject: RE: Simple C Language Question
>
>
>
> The only messing I want to do is really read from it.  However, would it
> make sense that for whatever data I can pull from there I can get using
> system calls?
>
> Where I am getting all this from is the acct.c source for the BSD Process
> Accounting.  I'm working on a kernel module that is similar to the BSD
> Process Accounting function but I'd like to try and 'improve' upon it.
>
>  In terms of effeciency, would doing a system call to _getpid be more
> effecient than either current->pid and getpid(). Remember this is for a
> kernel module.
>
> Thanks for all your help.  It sounds like I didn't do enough research in
> looking through the header files.
>
> Thanks,
> Scott
>
> ----------------------------------------------------------------------
> ----------
>
> Scott Bowling
> Analyst Programmer
> DST Systems
> 816.435.4447
> SABowling at dstsystems.com
>
>
>
>
>                     "Jeremy
>
>                     Fowler"              To:     "Scott Bowling"
>
>                     <jfowler at westr
> <sbowling at bowlingkyler.com>, "Kansas City
>                     ope.com>              Linux Users Group Mailing
> List"
>                                           <kclug at kclug.org>
>
>                     11/19/2002           cc:
>
>                     10:06 AM             Subject:     RE: Simple C
> Language Question
>
>
>
>
>
>
>
>
>
> Also, you shouldn't mess with the task table unless you really know what
> your
> doing. If all you want is to get the current pid, use the getpid function
> defined in the unistd.h file. See the getpid man file for more info.
>
> > -----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