RE: COW and mprotect on non-shared memory

2003-08-14 Thread Luoqi Chen
> For that reason, when you mprotect an area of non-shared, anonymous > memory to no access and then back to writable, Linux has no way of > knowing that the memory wasn't set for COW before you make it > unwritable. It goes ahead and makes all the pages in the area COW. > > That means that if I

Re: COW and mprotect on non-shared memory

2003-08-14 Thread Ed L Cashin
"Luoqi Chen" <[EMAIL PROTECTED]> writes: [Ed writes] >> That means that if I do this: >> >> for (i = 0; i < n; ++i) { >> assert(!mprotect(p, pgsiz, PROT_NONE)); >> assert(!mprotect(p, pgsiz, PROT_READ|PROT_WRITE|PROT_EXEC)); >> p[i] = i & 0xff; >> } >> >> ... I get n mi

Re: COW and mprotect on non-shared memory

2003-08-10 Thread David Schultz
On Thu, Aug 07, 2003, Ed L Cashin wrote: > "Luoqi Chen" <[EMAIL PROTECTED]> writes: > > [Ed writes] > >> That means that if I do this: > >> > >> for (i = 0; i < n; ++i) { > >> assert(!mprotect(p, pgsiz, PROT_NONE)); > >> assert(!mprotect(p, pgsiz, PROT_READ|PROT_WRITE|PROT_EXEC));