Thread (2 messages) 2 messages, 2 authors, 2003-02-03

Re: [question] shm_nattch in sys_shmat?

From: Matthew Dobson <hidden>
Date: 2003-02-03 23:43:16

Christoph Rohland wrote:
Hi Matthew,

On Fri, 31 Jan 2003, Matthew Dobson wrote:
quoted
sys_shmat, does in fact increment shm_nattch, but only to
decrement it again a few lines later, as seen in this code
snippet.  Can anyone please explain why this is?

sys_shmat temporarily increases shm_nattch to make sure it's never zero:

quoted
quoted
quoted
quoted
shp->shm_nattch++;

Make sure shm_nattch is greater than zero.

quoted
quoted
user_addr = (void*) do_mmap (file, addr, size, prot,

map the segment which increments shm_nattch in shm_mmap accounting for
the actual mapping

quoted
quoted
quoted
quoted
shp->shm_nattch--;

Correct it again.

Greetings
		Christoph
Ah ha...   I hadn't followed the do_mmap call chain deep enough to 
notice that it would call the shm_mmap call through the f_op function 
pointer.  Thanks for pointing that out.  It makes much more sense now. 
A small comment in there would make it *much* more obvious what is going on.

Cheers!

-Matt

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help