/[rtmk]/rtmk/ipc-mqueue.c
ViewVC logotype

Diff of /rtmk/ipc-mqueue.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jrydberg, Fri Dec 7 22:08:23 2001 UTC revision 1.2 by jrydberg, Thu Feb 21 20:14:42 2002 UTC
# Line 1  Line 1 
1  /* IPC message queues.  /* IPC message queues.
2     Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org.     Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@rtmk.org.
3    
4  This program is free software; you can redistribute it and/or modify  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
# Line 19  Foundation, Inc., 59 Temple Place - Suit Line 19  Foundation, Inc., 59 Temple Place - Suit
19    
20  #include "ipc-mqueue.h"  #include "ipc-mqueue.h"
21  #include "ipc-kmsg.h"  #include "ipc-kmsg.h"
 #include "vm-slab.h"  
22  #include "trace.h"  #include "trace.h"
23    
 /* Cache for ipc mqueue structures.  */  
 static struct kmem_cache *mqueue_cache;  
   
24  /* Initialize the message queue system.  */  /* Initialize the message queue system.  */
25    
26  void  void
27  ipc_mqueue_init (void)  ipc_mqueue_init (void)
28  {  {
   mqueue_cache = kmem_cache_create ("ipc mqueue cache",  
                                     sizeof (struct ipc_mqueue), 0);  
   assert (mqueue_cache);  
29  }  }
30    
31  /* Create a new message queue for a port.  Returns a new queue  /* Create a new message queue for a port.  Returns a new queue
32     with default queue limit, NULL if we can not allocate memory.  */     with default queue limit, NULL if we can not allocate memory.  */
33    
34  struct ipc_mqueue *  void
35  ipc_mqueue_create (void)  ipc_mqueue_create (struct ipc_mqueue *imq)
36  {  {
37    struct ipc_mqueue *imq;    queue_init (& imq->queue);
     
   imq = (struct ipc_mqueue *) kmem_cache_alloc (mqueue_cache);  
   if (imq == 0)  
     return (struct ipc_mqueue *) 0;  
   
   queue_init (&imq->queue);  
38    imq->qlimit   = RTMK_PORT_QLIMIT_DEFAULT;    imq->qlimit   = RTMK_PORT_QLIMIT_DEFAULT;
39    imq->msgcount = 0;    imq->msgcount = 0;
   
   return imq;  
40  }  }
41    
42  /* Destroy message queue, releasing all messages on it.  */  /* Destroy message queue, releasing all messages on it.  */
# Line 74  ipc_mqueue_destroy (struct ipc_mqueue *i Line 59  ipc_mqueue_destroy (struct ipc_mqueue *i
59            ikm = next;            ikm = next;
60          }          }
61      }      }
       
   kmem_cache_free (mqueue_cache, imq);  
62  }  }
63    
64  /* This function tries to enqueue a kernel message on the message  /* This function tries to enqueue a kernel message on the message

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26