MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / tty_watermarks

Function tty_watermarks

components/lwp/terminal/freebsd/tty.c:102–128  ·  view source on GitHub ↗

* Allocate buffer space if necessary, and set low watermarks, based on speed. * Note that the ttyxxxq_setsize() functions may drop and then reacquire the tty * lock during memory allocation. They will return ENXIO if the tty disappears * while unlocked. */

Source from the content-addressed store, hash-verified

100 * while unlocked.
101 */
102static int tty_watermarks(struct lwp_tty *tp)
103{
104 size_t bs = 0;
105 int error;
106
107 /* Provide an input buffer for 2 seconds of data. */
108 if (tp->t_termios.c_cflag & CREAD)
109 bs =
110 MIN(bsd_speed_to_integer(tp->t_termios.__c_ispeed) / 5, TTYBUF_MAX);
111 error = ttyinq_setsize(&tp->t_inq, tp, bs);
112 if (error != 0)
113 return error;
114
115 /* Set low watermark at 10% (when 90% is available). */
116 tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10;
117
118 /* Provide an output buffer for 2 seconds of data. */
119 bs = MIN(bsd_speed_to_integer(tp->t_termios.__c_ospeed) / 5, TTYBUF_MAX);
120 error = ttyoutq_setsize(&tp->t_outq, tp, bs);
121 if (error != 0)
122 return error;
123
124 /* Set low watermark at 10% (when 90% is available). */
125 tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10;
126
127 return 0;
128}
129
130/**
131 * Drain outq

Callers 2

ttydev_openFunction · 0.85
tty_generic_ioctlFunction · 0.85

Calls 5

bsd_speed_to_integerFunction · 0.85
ttyinq_setsizeFunction · 0.85
ttyinq_getallocatedsizeFunction · 0.85
ttyoutq_setsizeFunction · 0.85
ttyoutq_getallocatedsizeFunction · 0.85

Tested by

no test coverage detected