Put serializing lock in OS2_create_queue to guarantee atomic update to
authorChris Hanson <org/chris-hanson/cph>
Thu, 5 Jan 1995 23:36:07 +0000 (23:36 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 5 Jan 1995 23:36:07 +0000 (23:36 +0000)
global counter variable.

v7/src/microcode/os2.c

index 962cd8437495543596d97b02e7ff88013922808b..1d582f00c745cc8022ae68ae92091fe11004a2de 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: os2.c,v 1.2 1994/12/19 22:30:05 cph Exp $
+$Id: os2.c,v 1.3 1995/01/05 23:36:07 cph Exp $
 
-Copyright (c) 1994 Massachusetts Institute of Technology
+Copyright (c) 1994-95 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -140,13 +140,19 @@ OS2_wait_event_semaphore (HEV s, int blockp)
   return (1);
 }
 \f
+HMTX OS2_create_queue_lock;
+
 HQUEUE
 OS2_create_queue (ULONG priority)
 {
   static unsigned int n = 0;
+  unsigned int this_n;
   char buffer [64];
   HQUEUE result;
-  sprintf (buffer, "\\queues\\scm%d\\%d.que", OS2_scheme_pid, (n++));
+  OS2_request_mutex_semaphore (OS2_create_queue_lock);
+  this_n = (n++);
+  OS2_release_mutex_semaphore (OS2_create_queue_lock);
+  sprintf (buffer, "\\queues\\scm%d\\%d.que", OS2_scheme_pid, this_n);
   STD_API_CALL (dos_create_queue, ((&result), priority, buffer));
   return (result);
 }