summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
21fc456)
fix: incorrect control flow in getcwd(2) syscall
12 files changed:
// LunaixOS related
#define LUNAIX_SYS_PANIC 32
#define LUNAIX_SYS_CALL 33
// LunaixOS related
#define LUNAIX_SYS_PANIC 32
#define LUNAIX_SYS_CALL 33
#define EX_INTERRUPT_BEGIN 200
#define EX_INTERRUPT_BEGIN 200
+static inline void
+cpu_int(int vect)
+{
+ asm("int %0" ::"i"(vect));
+}
+
void
cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low);
void
cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low);
#endif /* __LUNAIX_SCHEDULER_H */
#endif /* __LUNAIX_SCHEDULER_H */
// We make this a non-trap entry, and enable interrupt
// only when needed!
_set_idt_intr_entry(LUNAIX_SYS_CALL, 0x08, _asm_isr33, 3);
// We make this a non-trap entry, and enable interrupt
// only when needed!
_set_idt_intr_entry(LUNAIX_SYS_CALL, 0x08, _asm_isr33, 3);
+
+ _set_idt_intr_entry(LUNAIX_SCHED, 0x08, _asm_isr34, 0);
}
\ No newline at end of file
}
\ No newline at end of file
isr_template LUNAIX_SYS_PANIC
isr_template LUNAIX_SYS_CALL
isr_template LUNAIX_SYS_PANIC
isr_template LUNAIX_SYS_CALL
+ isr_template LUNAIX_SCHED
isr_template APIC_ERROR_IV
isr_template APIC_LINT0_IV
isr_template APIC_ERROR_IV
isr_template APIC_LINT0_IV
#include <arch/x86/interrupts.h>
#include <lunaix/lxconsole.h>
#include <lunaix/process.h>
#include <arch/x86/interrupts.h>
#include <lunaix/lxconsole.h>
#include <lunaix/process.h>
+#include <lunaix/sched.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
#include <lunaix/tty/tty.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
#include <lunaix/tty/tty.h>
+void
+intr_routine_sched(const isr_param* param)
+{
+ schedule();
+}
+
void
intr_routine_init()
{
void
intr_routine_init()
{
intr_subscribe(FAULT_GENERAL_PROTECTION, intr_routine_general_protection);
intr_subscribe(FAULT_PAGE_FAULT, intr_routine_page_fault);
intr_subscribe(FAULT_STACK_SEG_FAULT, intr_routine_page_fault);
intr_subscribe(FAULT_GENERAL_PROTECTION, intr_routine_general_protection);
intr_subscribe(FAULT_PAGE_FAULT, intr_routine_page_fault);
intr_subscribe(FAULT_STACK_SEG_FAULT, intr_routine_page_fault);
intr_subscribe(LUNAIX_SYS_PANIC, intr_routine_sys_panic);
intr_subscribe(LUNAIX_SYS_PANIC, intr_routine_sys_panic);
+ intr_subscribe(LUNAIX_SCHED, intr_routine_sched);
+
intr_subscribe(APIC_SPIV_IV, intr_routine_apic_spi);
intr_subscribe(APIC_ERROR_IV, intr_routine_apic_error);
intr_subscribe(APIC_SPIV_IV, intr_routine_apic_spi);
intr_subscribe(APIC_ERROR_IV, intr_routine_apic_error);
- cpu_enable_interrupt();
- errno = file->ops.read(file, buf, count, file->f_pos);
- cpu_disable_interrupt();
+ __SYSCALL_INTERRUPTIBLE(
+ { errno = file->ops.read(file, buf, count, file->f_pos); })
if (errno > 0) {
file->f_pos += errno;
if (errno > 0) {
file->f_pos += errno;
- cpu_enable_interrupt();
- errno = file->ops.write(file, buf, count, file->f_pos);
- cpu_disable_interrupt();
+ __SYSCALL_INTERRUPTIBLE(
+ { errno = file->ops.write(file, buf, count, file->f_pos); })
if (errno > 0) {
file->f_pos += errno;
if (errno > 0) {
file->f_pos += errno;
if (!__current->cwd) {
*buf = PATH_DELIM;
if (!__current->cwd) {
*buf = PATH_DELIM;
- goto done;
- }
-
- size_t len = vfs_get_path(__current->cwd, buf, size, 0);
- if (len == size) {
- errno = ERANGE;
- goto done;
+ len = 1;
+ } else {
+ len = vfs_get_path(__current->cwd, buf, size, 0);
+ if (len == size) {
+ errno = ERANGE;
+ goto done;
+ }
// When a key is arrived, one of the processes will win the race and
// swallow it (advancing the key buffer pointer)
if (!kbd_recv_key(&keyevent)) {
// When a key is arrived, one of the processes will win the race and
// swallow it (advancing the key buffer pointer)
if (!kbd_recv_key(&keyevent)) {
continue;
}
if (!(keyevent.state & KBD_KEY_FPRESSED)) {
continue;
}
if (!(keyevent.state & KBD_KEY_FPRESSED)) {
+void
+sched_yieldk()
+{
+ cpu_int(LUNAIX_SCHED);
+}
+
__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
{
if (!seconds) {
__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
{
if (!seconds) {
}
wpid = wpid ? wpid : -__current->pgid;
}
wpid = wpid ? wpid : -__current->pgid;
- cpu_enable_interrupt();
repeat:
llist_for_each(proc, n, &__current->children, siblings)
{
repeat:
llist_for_each(proc, n, &__current->children, siblings)
{
- cpu_disable_interrupt();
status_flags |= PEXITSIG * (proc->sig_inprogress != 0);
if (status) {
*status = proc->exit_code | status_flags;
status_flags |= PEXITSIG * (proc->sig_inprogress != 0);
if (status) {
*status = proc->exit_code | status_flags;
struct mm_region *pos, *n;
llist_for_each(pos, n, &proc->mm.regions.head, head)
{
struct mm_region *pos, *n;
llist_for_each(pos, n, &proc->mm.regions.head, head)
{
}
vmm_mount_pd(PD_MOUNT_1, proc->page_table);
}
vmm_mount_pd(PD_MOUNT_1, proc->page_table);
{
__current->flags |= PROC_FINPAUSE;
{
__current->flags |= PROC_FINPAUSE;
- __SYSCALL_INTERRUPTIBLE({
- while ((__current->flags & PROC_FINPAUSE)) {
- sched_yield();
- }
- })
+ while ((__current->flags & PROC_FINPAUSE)) {
+ sched_yieldk();
+ }
+
__current->k_status = EINTR;
}
__current->k_status = EINTR;
}
-void
-sched_yield()
-{
- sched_ticks_counter = sched_ticks;
-}
-
static void
temp_intr_routine_rtc_tick(const isr_param* param)
{
static void
temp_intr_routine_rtc_tick(const isr_param* param)
{