[sheepdog] [PATCH 01/11] sheep: add helper functions to check the current thread

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Apr 16 09:24:29 CEST 2013


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/sheep_priv.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 4a3cd2e..6f19fc8 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -209,6 +209,16 @@ extern char *epoch_path;
 extern mode_t def_fmode;
 extern mode_t def_dmode;
 
+static inline bool is_main_thread(void)
+{
+	return gettid() == getpid();
+}
+
+static inline bool is_worker_thread(void)
+{
+	return !is_main_thread();
+}
+
 /* One should call this function to get sys->epoch outside main thread */
 static inline uint32_t sys_epoch(void)
 {
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list