rwlock.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __RWLOCKS_H__
  17. #define __RWLOCKS_H__
  18. #include <stdint.h>
  19. #include <starpu.h>
  20. typedef struct starpu_rw_lock_s {
  21. uint32_t busy;
  22. uint8_t writer;
  23. uint16_t readercnt;
  24. } starpu_rw_lock_t;
  25. void _starpu_init_rw_lock(starpu_rw_lock_t *lock);
  26. void _starpu_take_rw_lock_write(starpu_rw_lock_t *lock);
  27. void _starpu_take_rw_lock_read(starpu_rw_lock_t *lock);
  28. int _starpu_take_rw_lock_write_try(starpu_rw_lock_t *lock);
  29. int _starpu_take_rw_lock_read_try(starpu_rw_lock_t *lock);
  30. void _starpu_release_rw_lock(starpu_rw_lock_t *lock);
  31. ///* make sure to have the lock before using that function */
  32. //inline uint8_t _starpu_rw_lock_is_writer(starpu_rw_lock_t *lock);
  33. //unsigned _starpu_is_rw_lock_referenced(starpu_rw_lock_t *lock);
  34. #endif