All of lore.kernel.org
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: "SATHISH.J" <sathish.j@tatainfotech.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Reg:current a pointer to task_struct
Date: Mon, 18 Jun 2001 02:06:19 -0700	[thread overview]
Message-ID: <3B2DC48B.392795A7@mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.10.10106181403400.9461-100000@blrmail>

"SATHISH.J" wrote:
> 
> Hi,
> 
> Please help me with the following:
> 
> I tried to go through get_current function which is in assembly.
> 
> static inline struct task_struct * get_current(void) {
>         struct task_struct *current;
>         __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
>         return current;
>  }
> 
> Please tell me what is done here. Does current refer to process onproc.

Actually the code returns the stack pointer (esp) anded with ~8191
(FFFE000).

The trick is that kernel task structures are allocated at the low end of
the kernel stack for each task.  The stack is a the high end of the
address range and works down.  (Kernel stack overflow will "eat" the
task structure.)

current is (struct tast_struct *) and points to the task_struc for the
current task (how could it be otherwise, given that it comes from the
tasks stack pointer).

George

  parent reply	other threads:[~2001-06-18  9:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.10.10106031716330.3971-100000@blrmail>
2001-06-04 16:34 ` Reg mkdir syscall SATHISH.J
2001-06-05  5:02   ` H. Peter Anvin
2001-06-08  6:26 ` Reg compiling of source code SATHISH.J
2001-06-14  7:52   ` Reg-directory size SATHISH.J
2001-06-14  8:53     ` Daniel Phillips
2001-06-14 10:23     ` RAM filesystem directory size SATHISH.J
2001-06-15 10:22       ` Reg file system hash function SATHISH.J
2001-06-15 10:30         ` Russell King
2001-06-17  8:06         ` Reg:dentry->d_mounts value SATHISH.J
2001-06-17  8:14           ` Reg:magic number of the filesystem SATHISH.J
2001-06-17  8:21             ` Reg:use of file_system_type structure SATHISH.J
2001-06-17  8:21               ` Alexander Viro
2001-06-18  7:56               ` function of getname() function SATHISH.J
2001-06-18  7:42                 ` Alexander Viro
2001-06-18  7:47                 ` Tigran Aivazian
2001-06-18  8:35                 ` Reg:current a pointer to task_struct SATHISH.J
2001-06-18  8:49                   ` Reg putname() function SATHISH.J
2001-06-18  9:06                   ` george anzinger [this message]
2001-06-20  9:41                 ` filldir() function SATHISH.J
2001-06-20 22:26                   ` Jan Kara
2001-06-25  7:11                   ` Reg Kernel Debugger kdb SATHISH.J
2001-06-25  7:33                     ` siva kumar
2001-06-25  8:36                     ` Keith Owens
2001-06-26  4:54                     ` Reg Kernel Debugger kgdb SATHISH.J
2001-06-26 10:01                       ` using gdb to debug kernel SATHISH.J
2001-06-26 10:57                         ` Lars Marowsky-Bree
2001-06-26 11:10                         ` Reg installing a patch on linux SATHISH.J
2001-06-26 16:17                     ` Reg Kernel Debugger kgdb Timur Tabi
2001-06-21 12:06               ` Reg:use of file_system_type structure Anuradha Ratnaweera
2001-06-17  8:26             ` Reg:magic number of the filesystem Alexander Viro
2001-06-11  4:59 ` exec format error SATHISH.J
2001-06-11  6:08   ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B2DC48B.392795A7@mvista.com \
    --to=george@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sathish.j@tatainfotech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.