From 81751d99cc58e689e447487a05b2d3eb94841837 Mon Sep 17 00:00:00 2001 From: prife Date: Thu, 7 Feb 2013 23:21:19 +0800 Subject: [PATCH] fix bug in simulator/drivers/serial.c which deadlock may happen if multi-uart both output use printf --- bsp/simulator/drivers/serial.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bsp/simulator/drivers/serial.c b/bsp/simulator/drivers/serial.c index 420143aec4..7593959599 100755 --- a/bsp/simulator/drivers/serial.c +++ b/bsp/simulator/drivers/serial.c @@ -151,6 +151,7 @@ static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size) { + int level; #if _DEBUG_SERIAL==1 printf("in rt_serial_write()\n"); #endif @@ -162,8 +163,10 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buff fwrite(buffer, size, 1, fp); #endif + level = rt_hw_interrupt_disable(); printf("%s", (char *)buffer); fflush(stdout); + rt_hw_interrupt_enable(level); return size; }