All of lore.kernel.org
 help / color / mirror / Atom feed
* Can mm_struct of a process be null?
@ 2013-11-15 16:24 Paul Davies C
  2013-11-15 16:31 ` Daniel Baluta
  2013-11-18  3:42 ` Chetan Nanda
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Davies C @ 2013-11-15 16:24 UTC (permalink / raw)
  To: kernelnewbies

Hi,
     I happen to find this code snippet in the kernel source :

**/*struct mm_struct *mm=current->mm**;**
**
     /* some other code */

**    if(mm){ /*<==Why is **this here? */**
**        /*read the contents by locking*/**
**    }

*/The/if /checks whether the mm_struct of the current process is NULL or 
not. That means the mm_struct of a process can become NULL. How can that 
happen?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131115/90060719/attachment.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Can mm_struct of a process be null?
  2013-11-15 16:24 Can mm_struct of a process be null? Paul Davies C
@ 2013-11-15 16:31 ` Daniel Baluta
  2013-11-18  3:42 ` Chetan Nanda
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Baluta @ 2013-11-15 16:31 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Nov 15, 2013 at 6:24 PM, Paul Davies C <pauldaviesc@gmail.com> wrote:
> Hi,
>     I happen to find this code snippet in the kernel source :
>
>     struct mm_struct *mm=current->mm;
>
>     /* some other code */
>
>     if(mm){ /*<==Why is this here? */
>         /*read the contents by locking*/
>     }
>
> The if  checks whether the mm_struct of the current process is NULL or not.
> That means the mm_struct of a process can become NULL. How can that happen?

mm_struct points to a process address space. It is NULL for kernel threads.

Daniel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Can mm_struct of a process be null?
  2013-11-15 16:24 Can mm_struct of a process be null? Paul Davies C
  2013-11-15 16:31 ` Daniel Baluta
@ 2013-11-18  3:42 ` Chetan Nanda
  1 sibling, 0 replies; 3+ messages in thread
From: Chetan Nanda @ 2013-11-18  3:42 UTC (permalink / raw)
  To: kernelnewbies

Yes, current->mm points to user space context for the current process.
Now for a kernel threads there is no user space context and for them
current->mm would be NULL.

Thanks,
Chetan Nanda


On Fri, Nov 15, 2013 at 9:54 PM, Paul Davies C <pauldaviesc@gmail.com>wrote:

>  Hi,
>     I happen to find this code snippet in the kernel source :
>
>
>
>
>
>
>
>
>
> *struct mm_struct *mm=current->mm;     /* some other code */     if(mm){
> /*<==Why is this here? */         /*read the contents by locking*/     } *
> The* if  *checks whether the mm_struct of the current process is NULL or
> not. That means the mm_struct of a process can become NULL. How can that
> happen?
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131118/18eb181f/attachment.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-18  3:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 16:24 Can mm_struct of a process be null? Paul Davies C
2013-11-15 16:31 ` Daniel Baluta
2013-11-18  3:42 ` Chetan Nanda

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.