Trying to get closer to the original OS/161 sources.

This commit is contained in:
Geoffrey Challen
2016-01-11 20:54:52 -05:00
parent 202cc3eab4
commit a6878c822b
13 changed files with 164 additions and 161 deletions

View File

@@ -194,16 +194,5 @@ void kprintf_bootstrap(void);
#define DIVROUNDUP(a,b) (((a)+(b)-1)/(b))
#define ROUNDUP(a,b) (DIVROUNDUP(a,b)*b)
void random_yielder(uint32_t);
void random_spinner(uint32_t);
/*
* Testing variants of kprintf. tprintf is silent during automated testing.
* sprintf prefixes the kernel secret to kprintf messages during automated
* testing. nprintf is not silent during automated testing.
*/
int tkprintf(const char *format, ...) __PF(1,2);
int nkprintf(const char *format, ...) __PF(1,2);
#endif /* _LIB_H_ */

View File

@@ -62,7 +62,7 @@ typedef __va_list va_list;
* or split the definition of va_list into another header file, none
* of which seems entirely desirable.
*/
int vkprintf(const char *fmt, va_list ap) __PF(1,0);
void vkprintf(const char *fmt, va_list ap) __PF(1,0);
int vsnprintf(char *buf, size_t maxlen, const char *fmt, va_list ap) __PF(3,0);
/*

View File

@@ -44,10 +44,10 @@
* internally.
*/
struct semaphore {
char *sem_name;
char *sem_name;
struct wchan *sem_wchan;
struct spinlock sem_lock;
volatile unsigned sem_count;
volatile unsigned sem_count;
};
struct semaphore *sem_create(const char *name, unsigned initial_count);
@@ -56,7 +56,7 @@ void sem_destroy(struct semaphore *);
/*
* Operations (both atomic):
* P (proberen): decrement count. If the count is 0, block until
* the count is 1 again before decrementing.
* the count is 1 again before decrementing.
* V (verhogen): increment count.
*/
void P(struct semaphore *);
@@ -73,9 +73,9 @@ void V(struct semaphore *);
* (should be) made internally.
*/
struct lock {
char *lk_name;
// add what you need here
// (don't forget to mark things volatile as needed)
char *lk_name;
// add what you need here
// (don't forget to mark things volatile as needed)
};
struct lock *lock_create(const char *name);
@@ -84,11 +84,11 @@ void lock_destroy(struct lock *);
/*
* Operations:
* lock_acquire - Get the lock. Only one thread can hold the lock at the
* same time.
* same time.
* lock_release - Free the lock. Only the thread holding the lock may do
* this.
* this.
* lock_do_i_hold - Return true if the current thread holds the lock;
* false otherwise.
* false otherwise.
*
* These operations must be atomic. You get to write them.
*/
@@ -112,9 +112,9 @@ bool lock_do_i_hold(struct lock *);
*/
struct cv {
char *cv_name;
// add what you need here
// (don't forget to mark things volatile as needed)
char *cv_name;
// add what you need here
// (don't forget to mark things volatile as needed)
};
struct cv *cv_create(const char *name);
@@ -122,8 +122,8 @@ void cv_destroy(struct cv *);
/*
* Operations:
* cv_wait - Release the supplied lock, go to sleep, and, after
* waking up again, re-acquire the lock.
* cv_wait - Release the supplied lock, go to sleep, and, after
* waking up again, re-acquire the lock.
* cv_signal - Wake up one thread that's sleeping on this CV.
* cv_broadcast - Wake up all threads sleeping on this CV.
*

View File

@@ -1,28 +0,0 @@
#ifndef _SYNCHPROBS_H_
#define _SYNCHPROBS_H_
/*
* Synchronization problem primitives.
*/
/*
* whalemating.c.
*/
void whalemating_init(void);
void whalemating_cleanup(void);
void male(void);
void female(void);
void matchmaker(void);
/*
* stoplight.c.
*/
void gostraight(uint32_t);
void turnleft(uint32_t);
void turnright(uint32_t);
void stoplight_init(void);
void stoplight_cleanup(void);
#endif /* _SYNCHPROBS_H_ */

View File

@@ -30,6 +30,9 @@
#ifndef _TEST_H_
#define _TEST_H_
/* Get __PF() for declaring printf-like functions. */
#include <cdefs.h>
#include "opt-synchprobs.h"
#include "opt-automationtest.h"
@@ -126,6 +129,30 @@ void inQuadrant(int);
void leaveIntersection(void);
int stoplight(int, char **);
/*
* Synchronization problem primitives.
*/
/*
* whalemating.c.
*/
void whalemating_init(void);
void whalemating_cleanup(void);
void male(void);
void female(void);
void matchmaker(void);
/*
* stoplight.c.
*/
void gostraight(uint32_t);
void turnleft(uint32_t);
void turnright(uint32_t);
void stoplight_init(void);
void stoplight_cleanup(void);
#endif
/*
@@ -138,4 +165,16 @@ int ll1test(int, char **);
int ll16test(int, char **);
#endif
void random_yielder(uint32_t);
void random_spinner(uint32_t);
/*
* Testing variants of kprintf. tprintf is silent during automated testing.
* sprintf prefixes the kernel secret to kprintf messages during automated
* testing. nprintf is not silent during automated testing.
*/
int tkprintf(const char *format, ...) __PF(1,2);
int nkprintf(const char *format, ...) __PF(1,2);
#endif /* _TEST_H_ */