mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 11:30:01 +08:00
[kservice] MT-safe output support (kprintf/kputs)
Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
@@ -15,7 +15,7 @@ config RT_USING_RYM
|
||||
default y
|
||||
endif
|
||||
|
||||
config RT_USING_ULOG
|
||||
menuconfig RT_USING_ULOG
|
||||
bool "Enable ulog"
|
||||
default n
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user