MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tty_watermarks

Function tty_watermarks

freebsd/kern/tty.c:124–150  ·  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

122 * while unlocked.
123 */
124static int
125tty_watermarks(struct tty *tp)
126{
127 size_t bs = 0;
128 int error;
129
130 /* Provide an input buffer for 2 seconds of data. */
131 if (tp->t_termios.c_cflag & CREAD)
132 bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
133 error = ttyinq_setsize(&tp->t_inq, tp, bs);
134 if (error != 0)
135 return (error);
136
137 /* Set low watermark at 10% (when 90% is available). */
138 tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10;
139
140 /* Provide an output buffer for 2 seconds of data. */
141 bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
142 error = ttyoutq_setsize(&tp->t_outq, tp, bs);
143 if (error != 0)
144 return (error);
145
146 /* Set low watermark at 10% (when 90% is available). */
147 tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10;
148
149 return (0);
150}
151
152static int
153tty_drain(struct tty *tp, int leaving)

Callers 2

ttydev_openFunction · 0.85
tty_generic_ioctlFunction · 0.85

Calls 4

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

Tested by

no test coverage detected