struct proc;
struct kthread;
struct semaphore;
-struct semaphore_entry;
TAILQ_HEAD(kthread_tailq, kthread);
-LIST_HEAD(semaphore_list, semaphore_entry);
+TAILQ_HEAD(semaphore_tailq, semaphore);
+#define GENBUF_SZ 128 /* plan9 uses this as a scratch space, per syscall */
/* This captures the essence of a kernel context that we want to suspend. When
* a kthread is running, we make sure its stacktop is the default kernel stack,
/* ID, other shit, etc */
bool is_ktask; /* default is FALSE */
char *name;
+ char generic_buf[GENBUF_SZ];
};
/* Semaphore for kthreads to sleep on. 0 or less means you need to sleep */
int nr_signals;
spinlock_t lock;
bool irq_okay;
+#ifdef CONFIG_SEMAPHORE_DEBUG
+ TAILQ_ENTRY(semaphore) link;
+ bool is_on_list; /* would like better sys/queue.h */
+ uintptr_t bt_pc; /* program counter of last down */
+ uintptr_t bt_fp; /* frame pointer of last down */
+ uint32_t calling_core;
+#endif
};
struct cond_var {
bool irq_okay;
};
-/* TODO: consider building this into struct semaphore */
-struct semaphore_entry {
- struct semaphore sem;
- int fd;
- LIST_ENTRY(semaphore_entry) link;
+struct cv_lookup_elm {
+ TAILQ_ENTRY(cv_lookup_elm) link;
+ TAILQ_ENTRY(cv_lookup_elm) abortall_link; /* only used in abort_all */
+ struct cond_var *cv;
+ struct kthread *kthread;
+ struct syscall *sysc;
+ struct proc *proc;
+ atomic_t abort_in_progress; /* 0 = no */
};
+TAILQ_HEAD(cv_lookup_tailq, cv_lookup_elm);
uintptr_t get_kstack(void);
void put_kstack(uintptr_t stacktop);
bool sem_trydown_irqsave(struct semaphore *sem, int8_t *irq_state);
void sem_down_irqsave(struct semaphore *sem, int8_t *irq_state);
bool sem_up_irqsave(struct semaphore *sem, int8_t *irq_state);
+void print_sem_info(struct semaphore *sem);
+void print_all_sem_info(void);
void cv_init(struct cond_var *cv);
void cv_init_irqsave(struct cond_var *cv);
void cv_signal_irqsave(struct cond_var *cv, int8_t *irq_state);
void cv_broadcast_irqsave(struct cond_var *cv, int8_t *irq_state);
+bool abort_sysc(struct proc *p, struct syscall *sysc);
+void abort_all_sysc(struct proc *p);
+void __reg_abortable_cv(struct cv_lookup_elm *cle, struct cond_var *cv);
+void dereg_abortable_cv(struct cv_lookup_elm *cle);
+bool should_abort(struct cv_lookup_elm *cle);
+
+/* qlocks are plan9's binary sempahore, which are wrappers around our sems */
+typedef struct semaphore qlock_t;
+#define qlock_init(x) sem_init((x), 1)
+#define qlock(x) sem_down(x)
+#define qunlock(x) sem_up(x)
+#define canqlock(x) sem_trydown(x)
+
#endif /* ROS_KERN_KTHREAD_H */