locking.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. *
  3. * Copyright (C) 2001-2003 FhG Fokus
  4. *
  5. * This file is part of Kamailio, a free SIP server.
  6. *
  7. * Kamailio is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version
  11. *
  12. * Kamailio is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /*!
  22. * \file
  23. * \brief Kamailio core :: Kamailio locking library
  24. * \ingroup core
  25. * \author andrei
  26. * Module: \ref core
  27. *
  28. *
  29. Implements (in lock_ops.h & lock_alloc.h):
  30. simple locks:
  31. -------------
  32. type: gen_lock_t
  33. gen_lock_t* lock_alloc(); - allocates a lock in shared mem.
  34. gen_lock_t* lock_init(gen_lock_t* lock); - inits the lock
  35. void lock_destroy(gen_lock_t* lock); - removes the lock (e.g sysv rmid)
  36. void lock_dealloc(gen_lock_t* lock); - deallocates the lock's shared m.
  37. void lock_get(gen_lock_t* lock); - lock (mutex down)
  38. void lock_release(gen_lock_t* lock); - unlock (mutex up)
  39. lock sets:
  40. ----------
  41. type: gen_lock_set_t
  42. gen_lock_set_t* lock_set_alloc(no) - allocs a lock set in shm.
  43. gen_lock_set_t* lock_set_init(gen_lock_set_t* set); - inits the lock set
  44. void lock_set_destroy(gen_lock_set_t* s); - removes the lock set
  45. void lock_set_dealloc(gen_lock_set_t* s); - deallocs the lock set shm.
  46. void lock_set_get(gen_lock_set_t* s, int i); - locks sem i from the set
  47. void lock_set_release(gen_lock_set_t* s, int i) - unlocks sem i from the set
  48. WARNING: - lock_set_init may fail for large number of sems (e.g. sysv).
  49. - signals are not treated! (some locks are "awakened" by the signals)
  50. */
  51. #ifndef _locking_h
  52. #define _locking_h
  53. /* the order is important */
  54. #include "lock_ops.h"
  55. #include "lock_alloc.h"
  56. #endif