We use a unique key for every allocation instead of a static one which may have
already been used by another process. In the case where a key has been assigned 
to a
memory region with a different size compared to the one we currently
want to allocate, shmget() will fail with -EINVAL error code.

Signed-off-by: Markos Chandras <[email protected]>
---
 testcases/kernel/mem/mtest07/shm_test.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/mem/mtest07/shm_test.c 
b/testcases/kernel/mem/mtest07/shm_test.c
index 29c626a..4e88ebc 100644
--- a/testcases/kernel/mem/mtest07/shm_test.c
+++ b/testcases/kernel/mem/mtest07/shm_test.c
@@ -290,7 +290,6 @@ main(int    argc,           /* number of input parameters   
              */
     int                thrd_ndx;       /* index into the array of thread ids   
      */
     int                th_status;      /* exit status of LWP's                 
      */
     int                map_size;       /* size of the file mapped.             
      */
-    int                shmkey   = 1969;/* key used to generate shmid by 
shmget()     */
     pthread_t  thrdid[30];     /* maxinum of 30 threads allowed              */
     long       chld_args[4];   /* arguments to the thread function           */
     char        *map_address=NULL;
@@ -339,7 +338,7 @@ main(int    argc,           /* number of input parameters   
              */
         srand(time(NULL)%100);
         map_size = (1 + (int)(1000.0*rand()/(RAND_MAX+1.0))) * 4096;

-        chld_args[1] = shmkey++;
+        chld_args[1] = IPC_PRIVATE;
         chld_args[2] = map_size;

        dprt("main(): thrd_ndx = %d map_address = %#x map_size = %d\n",
@@ -384,4 +383,4 @@ main(int    argc,           /* number of input parameters   
              */
         }
     }
     exit(0);
-}
\ No newline at end of file
+}
--
1.7.1



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to