Add chopstx_critical.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2020-06-23 13:29:14 +09:00
parent 86d805620c
commit afd1339c58
3 changed files with 29 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
/*
* chopstx.c - Threads and only threads.
*
* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019
* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
* Flying Stone Technology
* Author: NIIBE Yutaka <gniibe@fsij.org>
*
@@ -1700,3 +1700,23 @@ chopstx_conf_idle (int enable_sleep)
return r;
}
/**
* chopstx_critical - Construct a critical section
* @func: function to be called
* @arg: argument to function
*
* Run the function @func with @arg under CPU schedule lock.
* Return void * pointer.
*/
void *
chopstx_critical (void *func (void *), void *arg)
{
void *p;
chx_cpu_sched_lock ();
p = func (arg);
chx_cpu_sched_unlock ();
return p;
}