diff options
Diffstat (limited to 'include/nvgpu/cond.h')
| -rw-r--r-- | include/nvgpu/cond.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/include/nvgpu/cond.h b/include/nvgpu/cond.h new file mode 100644 index 0000000..49e9d1f --- /dev/null +++ b/include/nvgpu/cond.h | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | * copy of this software and associated documentation files (the "Software"), | ||
| 6 | * to deal in the Software without restriction, including without limitation | ||
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | * Software is furnished to do so, subject to the following conditions: | ||
| 10 | * | ||
| 11 | * The above copyright notice and this permission notice shall be included in | ||
| 12 | * all copies or substantial portions of the Software. | ||
| 13 | * | ||
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 20 | * DEALINGS IN THE SOFTWARE. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef NVGPU_COND_H | ||
| 24 | #define NVGPU_COND_H | ||
| 25 | |||
| 26 | #ifdef __KERNEL__ | ||
| 27 | #include <nvgpu/linux/cond.h> | ||
| 28 | #elif defined(__NVGPU_POSIX__) | ||
| 29 | #include <nvgpu/posix/cond.h> | ||
| 30 | #else | ||
| 31 | #include <nvgpu_rmos/include/cond.h> | ||
| 32 | #endif | ||
| 33 | |||
| 34 | /* | ||
| 35 | * struct nvgpu_cond | ||
| 36 | * | ||
| 37 | * Should be implemented per-OS in a separate library | ||
| 38 | */ | ||
| 39 | struct nvgpu_cond; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * nvgpu_cond_init - Initialize a condition variable | ||
| 43 | * | ||
| 44 | * @cond - The condition variable to initialize | ||
| 45 | * | ||
| 46 | * Initialize a condition variable before using it. | ||
| 47 | */ | ||
| 48 | int nvgpu_cond_init(struct nvgpu_cond *cond); | ||
| 49 | |||
| 50 | /** | ||
| 51 | * nvgpu_cond_signal - Signal a condition variable | ||
| 52 | * | ||
| 53 | * @cond - The condition variable to signal | ||
| 54 | * | ||
| 55 | * Wake up a waiter for a condition variable to check if its condition has been | ||
| 56 | * satisfied. | ||
| 57 | * | ||
| 58 | * The waiter is using an uninterruptible wait. | ||
| 59 | */ | ||
| 60 | int nvgpu_cond_signal(struct nvgpu_cond *cond); | ||
| 61 | |||
| 62 | /** | ||
| 63 | * nvgpu_cond_signal_interruptible - Signal a condition variable | ||
| 64 | * | ||
| 65 | * @cond - The condition variable to signal | ||
| 66 | * | ||
| 67 | * Wake up a waiter for a condition variable to check if its condition has been | ||
| 68 | * satisfied. | ||
| 69 | * | ||
| 70 | * The waiter is using an interruptible wait. | ||
| 71 | */ | ||
| 72 | int nvgpu_cond_signal_interruptible(struct nvgpu_cond *cond); | ||
| 73 | |||
| 74 | /** | ||
| 75 | * nvgpu_cond_broadcast - Signal all waiters of a condition variable | ||
| 76 | * | ||
| 77 | * @cond - The condition variable to signal | ||
| 78 | * | ||
| 79 | * Wake up all waiters for a condition variable to check if their conditions | ||
| 80 | * have been satisfied. | ||
| 81 | * | ||
| 82 | * The waiters are using an uninterruptible wait. | ||
| 83 | */ | ||
| 84 | int nvgpu_cond_broadcast(struct nvgpu_cond *cond); | ||
| 85 | |||
| 86 | /** | ||
| 87 | * nvgpu_cond_broadcast_interruptible - Signal all waiters of a condition | ||
| 88 | * variable | ||
| 89 | * | ||
| 90 | * @cond - The condition variable to signal | ||
| 91 | * | ||
| 92 | * Wake up all waiters for a condition variable to check if their conditions | ||
| 93 | * have been satisfied. | ||
| 94 | * | ||
| 95 | * The waiters are using an interruptible wait. | ||
| 96 | */ | ||
| 97 | int nvgpu_cond_broadcast_interruptible(struct nvgpu_cond *cond); | ||
| 98 | |||
| 99 | /** | ||
| 100 | * nvgpu_cond_destroy - Destroy a condition variable | ||
| 101 | * | ||
| 102 | * @cond - The condition variable to destroy | ||
| 103 | */ | ||
| 104 | void nvgpu_cond_destroy(struct nvgpu_cond *cond); | ||
| 105 | |||
| 106 | #endif /* NVGPU_COND_H */ | ||
