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,3 +1,7 @@
2020-06-23 NIIBE Yutaka <gniibe@fsij.org>
* chopstx.c (chopstx_critical): New.
2019-12-27 NIIBE Yutaka <gniibe@fsij.org>
* contrib/spi-st.c (check_transmit, put_data): Fix handling

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;
}

View File

@@ -1,7 +1,8 @@
/*
* chopstx.h - Threads and only threads.
*
* Copyright (C) 2013, 2016, 2017, 2018 Flying Stone Technology
* Copyright (C) 2013, 2016, 2017, 2018, 2020
* Flying Stone Technology
* Author: NIIBE Yutaka <gniibe@fsij.org>
*
* This file is a part of Chopstx, a thread library for embedded.
@@ -161,3 +162,5 @@ int chopstx_poll (uint32_t *usec_p, int n,
struct chx_poll_head *const pd_array[]);
int chopstx_conf_idle (int enable_sleep);
void *chopstx_critical (void *func (void *), void *arg);