Thread: System Call Table

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    96

    System Call Table

    I am trying to find the kernel function which the system call getpid() calls when it is invoked. However, when I look at the system call table all I am able to locate is the number associated with it (20) but no location of the file is given. Where would I have to look on the system to find this. Thank you!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by NuNn View Post
    I am trying to find the kernel function which the system call getpid() calls when it is invoked. However, when I look at the system call table all I am able to locate is the number associated with it (20) but no location of the file is given. Where would I have to look on the system to find this. Thank you!
    Most of the system calls that don't have architectural dependencies can be found in src/kernel/... Just grep for it.

    If all else fails, use a sledgehammer:

    Code:
    $ grep -Hrl getpid /path/to/kernel/src
    But be prepared to wade through the output to find the actual definition.

    Personally, I just use cscope and index the kernel source.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I like this a lot for finding definitions in source code, it works like a recursive grep (eg, start at /usr/include) but there's a GUI to organize the information in a more helpful friendly way, so you can sort the wheat from the chaff or whatever, and get a better picture of context than with your normal grep.

    Also I wrote it, so it is guaranteed to work for me Read the "Simple Command Lookup" under "uses" on the webpage and you will get the idea.
    Last edited by MK27; 03-26-2009 at 12:30 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Or use LXR / The Linux Cross Reference - we actually use the same tool at work for our source-code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Table tennis scoring system
    By Saimadhav in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2008, 06:55 AM
  2. send() system call using _asm and interrupt
    By raghu2383 in forum C Programming
    Replies: 3
    Last Post: 09-25-2008, 02:38 AM
  3. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  4. Multiple types in lists, vectors or arrays.
    By megatron09 in forum C++ Programming
    Replies: 20
    Last Post: 08-31-2006, 01:54 PM
  5. system call
    By fnoyan in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2006, 10:53 AM