lkml.org 
[lkml]   [2009]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: mmap syscall problem
Date
On Monday 06 July 2009, Michal Simek wrote:
> > *p1 = 0xaa; *p2 = 0x55;
> >
> I closed fd too.
> close(fd);
> > return *p1; /* returns 0xaa if broken, 0x55 if correct */
> > }

If you close the fd between the assignment and reading
from the pointer again, the test case becomes invalid because of
timing. Closing the fd before the '*p1 = 0xaa' should be fine,
but unnecessary.

I also realized that you might need to mark the pointers
as 'volatile' so that the compiler has to do the operations
in order.

> >
> # ls -la existing-4k-file
> -rw-rw-r-- 1 monstr monstr 4096 Jul 6 2009 existing-4k-file
>
> # ./test-arnd
> # echo $?
> 85

Ok, so inside a single task, this does not happen.

> # dd if=existing-4k-file of=/dev/console count=1 2>/dev/null
> U#
>
> in file is first char U (0x55) which is IMO correct.

Right, though that was not part of the test, I'd expect this in
the file even if the return value was broken.

Arnd <><


\
 
 \ /
  Last update: 2009-07-06 17:09    [W:0.365 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site