[kservice] MT-safe output support (kprintf/kputs)

Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
Shell
2024-01-16 00:59:18 +08:00
committed by Meco Man
parent 447a22a21d
commit f6fce5f8d7
9 changed files with 189 additions and 41 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ config RT_USING_RYM
default y
endif
config RT_USING_ULOG
menuconfig RT_USING_ULOG
bool "Enable ulog"
default n
+1 -14
View File
@@ -22,20 +22,7 @@ static struct ulog_backend console = { 0 };
void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
const char *log, rt_size_t len)
{
#ifdef RT_USING_DEVICE
rt_device_t dev = rt_console_get_device();
if (dev == RT_NULL)
{
rt_hw_console_output(log);
}
else
{
rt_device_write(dev, 0, log, len);
}
#else
rt_hw_console_output(log);
#endif
rt_kputs(log);
}
+2 -2
View File
@@ -191,7 +191,7 @@ static void output_unlock(void)
}
/* If the scheduler is started and in thread context */
if (rt_interrupt_get_nest() == 0 && rt_thread_self() != RT_NULL)
if (rt_scheduler_is_available())
{
rt_mutex_release(&ulog.output_locker);
}
@@ -212,7 +212,7 @@ static void output_lock(void)
}
/* If the scheduler is started and in thread context */
if (rt_interrupt_get_nest() == 0 && rt_thread_self() != RT_NULL)
if (rt_scheduler_is_available())
{
rt_mutex_take(&ulog.output_locker, RT_WAITING_FOREVER);
}