Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 759711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:37:47+00:00 2026-05-14T15:37:47+00:00

The kernel is 2.4. On a side note, does anybody knows a good place

  • 0

The kernel is 2.4.

On a side note, does anybody knows a good place where I can search for that kind of information? Searching Google for function definitions is frustrating.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:37:48+00:00Added an answer on May 14, 2026 at 3:37 pm

    If you plan on spending any significant time searching through or understanding the Linux kernel, I recommend downloading a copy and using Cscope.

    Using Cscope on large projects (example: the Linux kernel)


    I found the following in a copy of the Linux kernel 2.4.18.

    The key seems to be the comment before this last piece of code below. It appears that the return value of sched_find_first_bit is undefined if no bit is set.

    From linux-2.4/include/linux/sched.h:185

    
    /*
     * The maximum RT priority is configurable.  If the resulting
     * bitmap is 160-bits , we can use a hand-coded routine which
     * is optimal.  Otherwise, we fall back on a generic routine for
     * finding the first set bit from an arbitrarily-sized bitmap.
     */
    #if MAX_PRIO  127
    #define sched_find_first_bit(map)   _sched_find_first_bit(map)
    #else
    #define sched_find_first_bit(map)   find_first_bit(map, MAX_PRIO)
    #endif
    

    From linux-2.4/include/asm-i386/bitops.h:303

    
    /**
     * find_first_bit - find the first set bit in a memory region
     * @addr: The address to start the search at
     * @size: The maximum size to search
     *
     * Returns the bit-number of the first set bit, not the number of the byte
     * containing a bit.
     */
    static __inline__ int find_first_bit(void * addr, unsigned size)
    {
        int d0, d1;
        int res;
    
        /* This looks at memory. Mark it volatile to tell gcc not to move it around */
        __asm__ __volatile__(
            "xorl %%eax,%%eax\n\t"
            "repe; scasl\n\t"
            "jz 1f\n\t"
            "leal -4(%%edi),%%edi\n\t"
            "bsfl (%%edi),%%eax\n"
            "1:\tsubl %%ebx,%%edi\n\t"
            "shll $3,%%edi\n\t"
            "addl %%edi,%%eax"
            :"=a" (res), "=&c" (d0), "=&D" (d1)
            :"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
        return res;
    }
    

    From linux-2.4/include/asm-i386/bitops.h:425

    
    /*
     * Every architecture must define this function. It's the fastest
     * way of searching a 140-bit bitmap where the first 100 bits are
     * unlikely to be set. It's guaranteed that at least one of the 140
     * bits is cleared.
     */
    static inline int _sched_find_first_bit(unsigned long *b)
    {
        if (unlikely(b[0]))
            return __ffs(b[0]);
        if (unlikely(b[1]))
            return __ffs(b[1]) + 32;
        if (unlikely(b[2]))
            return __ffs(b[2]) + 64;
        if (b[3])
            return __ffs(b[3]) + 96;
        return __ffs(b[4]) + 128;
    }
    

    From linux-2.4/include/asm-i386/bitops.h:409

    
    /**
     * __ffs - find first bit in word.
     * @word: The word to search
     *
     * Undefined if no bit exists, so code should check against 0 first.
     */
    static __inline__ unsigned long __ffs(unsigned long word)
    {
        __asm__("bsfl %1,%0"
            :"=r" (word)
            :"rm" (word));
        return word;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that a kernel may be launched with the triple brackets syntax: kernel<<<NumOfBlocks,
I'm writing a kernel module that needs to read the value of bitrate from
I have a CUDA kernel that calls out to a series of device functions.
#kernel build system and can use its lanauge ifneq($(KERNELRELEASE),) obj-m:=helloworld.o else KDIR:= /lib/modules/2.6.33.3-85.fc13.i686/build all:
Kernel launches in CUDA are generally asynchronous, which (as I understand) means that once
I can guess that the latter explicitly indicates to treat the '1' as an
Hello Linux Kernel Driver Gurus! I'm writing a v4l2 driver for a camera that
I have a kernel that calls a device function inside an if statement. The
In reference to linux kernel, I would like to access the file structure information
I'm looking for a linux utility that can alter the payloads of network packets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.