Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6502

How does the kernel know what is the current thread?

$
0
0

Can someone please explain me this snippet of code here taken from linux kernel?

/*  * how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) __attribute_const__; static inline struct thread_info *current_thread_info(void) {        register unsigned long sp asm ("sp");        return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));}

Questions:

  1. what is __attribute_const__ ?
  2. what does this do register unsigned long sp asm ("sp");
  3. why (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); return apointer to the struct?

Viewing all articles
Browse latest Browse all 6502

Trending Articles