drivers/serial/serial.c: Optimize wait time in tcdram() for buffer emptying
According to the specification, the close function must wait until all data has been written before it closes the file (except O_NONBLOCK is set). The maximum waiting time for this is not specified. To be able to edit the file list of the process, the close function has to lock the file list semaphore. After that the close function of the serial driver is called. Waiting for the complete transmission of all data is done in the serial driver. This causes the semaphore to remain locked until all data has been sent. However, no other thread of the process can edit the file list for that time (open, close, dup2, etc.). This is not optimal in a multithreaded environment. Therefore, we have to keep the waiting time within the driver as short as possible.
This commit is contained in:
parent
2dbe7af7f3
commit
c6942f6137
|
@ -88,8 +88,8 @@
|
|||
|
||||
/* Timing */
|
||||
|
||||
#define HALF_SECOND_MSEC 500
|
||||
#define HALF_SECOND_USEC 500000L
|
||||
#define POLL_DELAY_MSEC 1
|
||||
#define POLL_DELAY_USEC 1000
|
||||
|
||||
/************************************************************************************
|
||||
* Private Types
|
||||
|
@ -471,9 +471,9 @@ static int uart_tcdrain(FAR uart_dev_t *dev)
|
|||
while (!uart_txempty(dev))
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
nxsig_usleep(HALF_SECOND_USEC);
|
||||
nxsig_usleep(POLL_DELAY_USEC);
|
||||
#else
|
||||
up_mdelay(HALF_SECOND_MSEC);
|
||||
up_mdelay(POLL_DELAY_MSEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue