Revert "Merging in 1.0.2."

This reverts commit 50cf3276e7.
This commit is contained in:
Geoffrey Challen
2017-01-09 22:52:13 -05:00
parent 50cf3276e7
commit e318e3171e
118 changed files with 3158 additions and 1350 deletions

View File

@@ -35,6 +35,7 @@
#include <threadlist.h>
#include <machine/vm.h> /* for TLBSHOOTDOWN_MAX */
extern unsigned num_cpus;
/*
* Per-cpu structure
@@ -74,21 +75,24 @@ struct cpu {
* Accessed by other cpus.
* Protected by the IPI lock.
*
* TLB shootdown requests made to this CPU are queued in
* c_shootdown[], with c_numshootdown holding the number of
* requests. TLBSHOOTDOWN_MAX is the maximum number that can
* be queued at once, which is machine-dependent.
* If c_numshootdown is -1 (TLBSHOOTDOWN_ALL), all mappings
* should be invalidated. This is used if more than
* TLBSHOOTDOWN_MAX mappings are going to be invalidated at
* once. TLBSHOOTDOWN_MAX is MD and chosen based on when it
* becomes more efficient just to flush the whole TLB.
*
* The contents of struct tlbshootdown are also machine-
* dependent and might reasonably be either an address space
* and vaddr pair, or a paddr, or something else.
* struct tlbshootdown is machine-dependent and might
* reasonably be either an address space and vaddr pair, or a
* paddr, or something else.
*/
uint32_t c_ipi_pending; /* One bit for each IPI number */
struct tlbshootdown c_shootdown[TLBSHOOTDOWN_MAX];
unsigned c_numshootdown;
int c_numshootdown;
struct spinlock c_ipi_lock;
};
#define TLBSHOOTDOWN_ALL (-1)
/*
* Initialization functions.
*

View File

@@ -129,6 +129,8 @@ uint32_t random(void);
void *kmalloc(size_t size);
void kfree(void *ptr);
void kheap_printstats(void);
void kheap_printused(void);
unsigned long kheap_getused(void);
void kheap_nextgeneration(void);
void kheap_dump(void);
void kheap_dumpall(void);

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);
@@ -137,5 +137,40 @@ void cv_wait(struct cv *cv, struct lock *lock);
void cv_signal(struct cv *cv, struct lock *lock);
void cv_broadcast(struct cv *cv, struct lock *lock);
/*
* Reader-writer locks.
*
* When the lock is created, no thread should be holding it. Likewise,
* when the lock is destroyed, no thread should be holding it.
*
* The name field is for easier debugging. A copy of the name is
* (should be) made internally.
*/
struct rwlock {
char *rwlock_name;
// add what you need here
// (don't forget to mark things volatile as needed)
};
struct rwlock * rwlock_create(const char *);
void rwlock_destroy(struct rwlock *);
/*
* Operations:
* rwlock_acquire_read - Get the lock for reading. Multiple threads can
* hold the lock for reading at the same time.
* rwlock_release_read - Free the lock.
* rwlock_acquire_write - Get the lock for writing. Only one thread can
* hold the write lock at one time.
* rwlock_release_write - Free the write lock.
*
* These operations must be atomic. You get to write them.
*/
void rwlock_acquire_read(struct rwlock *);
void rwlock_release_read(struct rwlock *);
void rwlock_acquire_write(struct rwlock *);
void rwlock_release_write(struct rwlock *);
#endif /* _SYNCH_H_ */

View File

@@ -30,6 +30,13 @@
#ifndef _TEST_H_
#define _TEST_H_
/* Get __PF() for declaring printf-like functions. */
#include <cdefs.h>
#include <kern/secret.h>
#include "opt-synchprobs.h"
#include "opt-automationtest.h"
/*
* Declarations for test code and other miscellaneous high-level
* functions.
@@ -52,8 +59,18 @@ int threadtest2(int, char **);
int threadtest3(int, char **);
int semtest(int, char **);
int locktest(int, char **);
int locktest2(int, char **);
int locktest3(int, char **);
int cvtest(int, char **);
int cvtest2(int, char **);
int cvtest3(int, char **);
int cvtest4(int, char **);
int cvtest5(int, char **);
int rwtest(int, char **);
int rwtest2(int, char **);
int rwtest3(int, char **);
int rwtest4(int, char **);
int rwtest5(int, char **);
/* semaphore unit tests */
int semu1(int, char **);
@@ -88,11 +105,15 @@ int longstress(int, char **);
int createstress(int, char **);
int printfile(int, char **);
/* HMAC/hash tests */
int hmacu1(int, char**);
/* other tests */
int kmalloctest(int, char **);
int kmallocstress(int, char **);
int kmalloctest3(int, char **);
int kmalloctest4(int, char **);
int kmalloctest5(int, char **);
int nettest(int, char **);
/* Routine for running a user-level program. */
@@ -104,5 +125,75 @@ void menu(char *argstr);
/* The main function, called from start.S. */
void kmain(char *bootstring);
#if OPT_SYNCHPROBS
/*
* Synchronization driver primitives.
*/
void male_start(uint32_t);
void male_end(uint32_t);
void female_start(uint32_t);
void female_end(uint32_t);
void matchmaker_start(uint32_t);
void matchmaker_end(uint32_t);
int whalemating(int, char **);
void inQuadrant(int, uint32_t);
void leaveIntersection(uint32_t);
int stoplight(int, char **);
/*
* Synchronization problem primitives.
*/
/*
* whalemating.c.
*/
void whalemating_init(void);
void whalemating_cleanup(void);
void male(uint32_t);
void female(uint32_t);
void matchmaker(uint32_t);
/*
* stoplight.c.
*/
void gostraight(uint32_t, uint32_t);
void turnleft(uint32_t, uint32_t);
void turnright(uint32_t, uint32_t);
void stoplight_init(void);
void stoplight_cleanup(void);
#endif
/*
* Automation tests for detecting kernel deadlocks and livelocks.
*/
#if OPT_AUTOMATIONTEST
int dltest(int, char **);
int ll1test(int, char **);
int ll16test(int, char **);
#endif
void random_yielder(uint32_t);
void random_spinner(uint32_t);
/*
* kprintf variants that do not (or only) print during automated testing.
*/
#ifdef SECRET_TESTING
#define kprintf_t(...) kprintf(__VA_ARGS__)
#define kprintf_n(...) silent(__VA_ARGS__)
#else
#define kprintf_t(...) silent(__VA_ARGS__)
#define kprintf_n(...) kprintf(__VA_ARGS__)
#endif
static inline void silent(const char * fmt, ...) { (void)fmt; };
#endif /* _TEST_H_ */

View File

@@ -48,6 +48,7 @@ struct cpu;
/* Size of kernel stacks; must be power of 2 */
#define STACK_SIZE 4096
#define MAX_NAME_LENGTH 64
/* Mask for extracting the stack base address of a kernel stack pointer */
#define STACK_MASK (~(vaddr_t)(STACK_SIZE-1))
@@ -70,7 +71,16 @@ struct thread {
* These go up front so they're easy to get to even if the
* debugger is messed up.
*/
char *t_name; /* Name of this thread */
/*
* Name of this thread. Used to be dynamically allocated using kmalloc, but
* this can cause small changes in the amount of available memory due to the
* fact that it was cleaned up in exorcise. This produces more predictable
* behavior at the cost of a small amount of memory overhead and the
* inability to give threads huge names.
*/
char t_name[MAX_NAME_LENGTH];
const char *t_wchan_name; /* Name of wait channel, if sleeping */
threadstate_t t_state; /* State this thread is in */
@@ -168,5 +178,7 @@ void schedule(void);
*/
void thread_consider_migration(void);
extern unsigned thread_count;
void thread_wait_for_count(unsigned);
#endif /* _THREAD_H_ */

View File

@@ -34,7 +34,7 @@
* Leave this alone, so we can tell what version of the OS/161 base
* code we gave you.
*/
#define BASE_VERSION "2.0.2"
#define BASE_VERSION "2.0.1"
/*
* Change this as you see fit in the course of hacking the system.

View File

@@ -156,13 +156,6 @@ int vfs_getcwd(struct uio *buf);
* vfs_unmount - Unmount the filesystem presently mounted on the
* specified device.
*
* vfs_swapon - Look up DEVNAME and mark it as a swap device,
* returning a vnode. Similar to vfs_mount.
*
* vfs_swapoff - Unmark DEVNAME as a swap device. The vnode
* previously returned by vfs_swapon should be
* decref'd first. Similar to vfs_unmount.
*
* vfs_unmountall - Unmount all mounted filesystems.
*/
@@ -179,8 +172,6 @@ int vfs_mount(const char *devname, void *data,
struct device *dev,
struct fs **result));
int vfs_unmount(const char *devname);
int vfs_swapon(const char *devname, struct vnode **result);
int vfs_swapoff(const char *devname);
int vfs_unmountall(void);
/*

View File

@@ -55,7 +55,15 @@ int vm_fault(int faulttype, vaddr_t faultaddress);
vaddr_t alloc_kpages(unsigned npages);
void free_kpages(vaddr_t addr);
/*
* Return amount of memory (in bytes) used by allocated coremap pages. If
* there are ongoing allocations, this value could change after it is returned
* to the caller. But it should have been correct at some point in time.
*/
unsigned int coremap_used_bytes(void);
/* TLB shootdown handling called from interprocessor_interrupt */
void vm_tlbshootdown_all(void);
void vm_tlbshootdown(const struct tlbshootdown *);