Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/darwin Sync between parent and child in iohdisyst...



details:   https://anonhg.NetBSD.org/src/rev/c21794956ff6
branches:  trunk
changeset: 551856:c21794956ff6
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Sep 13 07:56:54 2003 +0000

description:
Sync between parent and child in iohdisystem thread so that the child has
time to get its parmeteres before the parent throw them away

diffstat:

 sys/compat/darwin/darwin_iohidsystem.c |  34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r b1c6ed152199 -r c21794956ff6 sys/compat/darwin/darwin_iohidsystem.c
--- a/sys/compat/darwin/darwin_iohidsystem.c    Sat Sep 13 07:56:03 2003 +0000
+++ b/sys/compat/darwin/darwin_iohidsystem.c    Sat Sep 13 07:56:54 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_iohidsystem.c,v 1.10 2003/09/11 23:16:19 manu Exp $ */
+/*     $NetBSD: darwin_iohidsystem.c,v 1.11 2003/09/13 07:56:54 manu Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.10 2003/09/11 23:16:19 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_iohidsystem.c,v 1.11 2003/09/13 07:56:54 manu Exp $");
 
 #include "ioconf.h"
 #include "wsmux.h"
@@ -86,7 +86,8 @@
 
 struct darwin_iohidsystem_thread_args {
        vaddr_t dita_shmem;
-       struct proc **dita_p;
+       struct proc *dita_p;
+       int dita_done;
 };
 
 #if 0
@@ -137,7 +138,6 @@
        case DARWIN_IOHIDCREATESHMEM: {
                /* Create the shared memory for HID events */
                int version;
-               struct proc *newpp;
                int error;
                size_t memsize;
                vaddr_t kvaddr;
@@ -175,10 +175,21 @@
 
                        dita = malloc(sizeof(*dita), M_TEMP, M_WAITOK);
                        dita->dita_shmem = kvaddr;
-                       dita->dita_p = &newpp;
+                       dita->dita_done = 0;
 
                        kthread_create1(darwin_iohidsystem_thread, 
-                           (void *)dita, &newpp, "iohidsystem");
+                           (void *)dita, &dita->dita_p, "iohidsystem");
+
+                       /* 
+                        * Make sure the thread got the informations
+                        * before exitting and destroying dita.
+                        */
+                       while (!dita->dita_done)
+                               (void)tsleep(&dita->dita_done, 
+                                   PZERO, "iohid_done", 0);
+
+                       free(dita, M_TEMP);
+
                }
                rep->rep_outcount = 0;
                break;
@@ -294,10 +305,16 @@
        printf("darwin_iohidsystem_thread: start\n");
 #endif
        dita = (struct darwin_iohidsystem_thread_args *)args;
-       shmem = (struct  darwin_iohidsystem_shmem *)dita->dita_shmem;
-       p = *dita->dita_p;
+       shmem = (struct darwin_iohidsystem_shmem *)dita->dita_shmem;
+       p = dita->dita_p;
        l = proc_representative_lwp(p);
 
+       /* 
+        * Allow the parent to get rid of dita.
+        */
+       dita->dita_done = 1;
+       wakeup(&dita->dita_done);
+
        evg = (struct darwin_iohidsystem_evglobals *)&shmem->dis_evglobals;
 
        /* Use the first wsmux available */
@@ -351,7 +368,6 @@
        }
 
 exit:
-       free(dita, M_TEMP);     
        kthread_exit(error);
        /* NOTREACHED */
 };



Home | Main Index | Thread Index | Old Index