aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-03-03 02:00:59 +0000
committersotech117 <michael_foiani@brown.edu>2024-03-03 02:00:59 +0000
commite8970e39cac119369177e32723c75ea585a94587 (patch)
treeed9513f584a5fad4e982791c3cd02c145f749e54
parent8c2e0ce946012a4275e8dfa9d8dfd1d5a68d6e3e (diff)
get text output to be displayed
-rw-r--r--kernel/drivers/tty/ldisc.c34
-rw-r--r--kernel/proc/sched.c7
2 files changed, 29 insertions, 12 deletions
diff --git a/kernel/drivers/tty/ldisc.c b/kernel/drivers/tty/ldisc.c
index dd67706..5651601 100644
--- a/kernel/drivers/tty/ldisc.c
+++ b/kernel/drivers/tty/ldisc.c
@@ -207,10 +207,11 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c)
vterminal_write(ldisc_to_tty(ldisc), "\n", 1);
// add the new char to the buffer
- ldisc->ldisc_buffer[ldisc->ldisc_tail] = c;
- ldisc->ldisc_tail = (ldisc->ldisc_tail + 1) % LDISC_BUFFER_SIZE;
- // set the buffer to full
- ldisc->ldisc_full = 1;
+ // ldisc->ldisc_buffer[ldisc->ldisc_tail] = c;
+ ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE;
+
+ // cook the buffer
+ ldisc->ldisc_cooked = ldisc->ldisc_head;
// wake up the thread that is sleeping on the wait queue of the line discipline
sched_wakeup_on(&ldisc->ldisc_read_queue, 0);
@@ -218,16 +219,14 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c)
case EOT:
// add the new char to the buffer
- ldisc->ldisc_buffer[ldisc->ldisc_tail] = c;
- ldisc->ldisc_tail = (ldisc->ldisc_tail + 1) % LDISC_BUFFER_SIZE;
- // set the buffer to full
- ldisc->ldisc_full = 1;
+ ldisc->ldisc_buffer[ldisc->ldisc_head] = c;
+ ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE;
// cook the buffer
- ldisc->ldisc_cooked = ldisc->ldisc_tail;
+ ldisc->ldisc_cooked = ldisc->ldisc_head;
// wake up the thread that is sleeping on the wait queue of the line discipline
- sched_wakeup_on(&ldisc->ldisc_read_queue, 0);
+ // sched_wakeup_on(&ldisc->ldisc_read_queue, 0);
break;
case ETX:
@@ -237,7 +236,20 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c)
default:
// if none applies, fallback to vterminal_key_pressed
- vterminal_key_pressed(ldisc_to_tty(ldisc));
+ // vterminal_write(ldisc_to_tty(ldisc), &c, 1);
+ ldisc->ldisc_buffer[ldisc->ldisc_head] = c;
+
+ // update the buffer if it's full
+ if ((ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE == ldisc->ldisc_tail)
+ {
+ ldisc->ldisc_full = 1;
+ }
+ else
+ {
+ ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE;
+ }
+
+ vterminal_key_pressed(&ldisc_to_tty(ldisc)->tty_vterminal);
break;
}
diff --git a/kernel/proc/sched.c b/kernel/proc/sched.c
index c8f209c..91264fa 100644
--- a/kernel/proc/sched.c
+++ b/kernel/proc/sched.c
@@ -333,8 +333,12 @@ void sched_wakeup_on(ktqueue_t *q, kthread_t **ktp)
{
// NOT_YET_IMPLEMENTED("PROCS: sched_wakeup_on");
- if (sched_queue_empty(q))
+ if (sched_queue_empty(q) || q == NULL)
{
+ if (ktp)
+ {
+ *ktp = NULL;
+ }
return;
}
@@ -344,6 +348,7 @@ void sched_wakeup_on(ktqueue_t *q, kthread_t **ktp)
{
*ktp = thr;
}
+
sched_make_runnable(thr);
intr_setipl(oldIPL);
}