Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

deleted files manually

  • Loading branch information...
commit e9b167c8648d8c53970fcef087fec47f268d1836 1 parent 93effd5
@Frankencelery Frankencelery authored
View
22 src/README.txt
@@ -1,22 +0,0 @@
-Grant Borthwick
-CIS 520
-Project 0
-
-To implement alarm-nega, I had to do three things.
-
-1. add alarm-mega.ck which is an exact copy of alarm-multiple with check_alarm (70); instead of check_alarm (7);
-
-2. Add {"alarm-mega", test_alarm_mega}, into tests.c
-
-3. Add extern test_func test_alarm_mega; into tests.h
-
-4. Add alarm-mega to the list of test names in Make.tests
-
-5. Add
-void
-test_alarm_mega (void)
-{
- test_sleep (5, 70);
-}
-
-into alarm-wait.c
View
429 src/devices/init.c
@@ -1,429 +0,0 @@
-#include "threads/init.h"
-#include <console.h>
-#include <debug.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <random.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "devices/kbd.h"
-#include "devices/input.h"
-#include "devices/serial.h"
-#include "devices/shutdown.h"
-#include "devices/timer.h"
-#include "devices/vga.h"
-#include "devices/rtc.h"
-#include "threads/interrupt.h"
-#include "threads/io.h"
-#include "threads/loader.h"
-#include "threads/malloc.h"
-#include "threads/palloc.h"
-#include "threads/pte.h"
-#include "threads/thread.h"
-#ifdef USERPROG
-#include "userprog/process.h"
-#include "userprog/exception.h"
-#include "userprog/gdt.h"
-#include "userprog/syscall.h"
-#include "userprog/tss.h"
-#else
-#include "tests/threads/tests.h"
-#endif
-#ifdef FILESYS
-#include "devices/block.h"
-#include "devices/ide.h"
-#include "filesys/filesys.h"
-#include "filesys/fsutil.h"
-#endif
-
-/* Page directory with kernel mappings only. */
-uint32_t *init_page_dir;
-
-#ifdef FILESYS
-/* -f: Format the file system? */
-static bool format_filesys;
-
-/* -filesys, -scratch, -swap: Names of block devices to use,
- overriding the defaults. */
-static const char *filesys_bdev_name;
-static const char *scratch_bdev_name;
-#ifdef VM
-static const char *swap_bdev_name;
-#endif
-#endif /* FILESYS */
-
-/* -ul: Maximum number of pages to put into palloc's user pool. */
-static size_t user_page_limit = SIZE_MAX;
-
-static void bss_init (void);
-static void paging_init (void);
-
-static char **read_command_line (void);
-static char **parse_options (char **argv);
-static void run_actions (char **argv);
-static void usage (void);
-
-#ifdef FILESYS
-static void locate_block_devices (void);
-static void locate_block_device (enum block_type, const char *name);
-#endif
-
-int main (void) NO_RETURN;
-
-/* Pintos main program. */
-int
-main (void)
-{
- char **argv;
-
- /* Clear BSS. */
- bss_init ();
-
- /* Break command line into arguments and parse options. */
- argv = read_command_line ();
- argv = parse_options (argv);
-
- /* Initialize ourselves as a thread so we can use locks,
- then enable console locking. */
- thread_init ();
- console_init ();
-
- /* Greet user. */
- printf ("Pintos booting with %'"PRIu32" kB RAM...\n",
- init_ram_pages * PGSIZE / 1024);
-
- /* Initialize memory system. */
- palloc_init (user_page_limit);
- malloc_init ();
- paging_init ();
-
- /* Segmentation. */
-#ifdef USERPROG
- tss_init ();
- gdt_init ();
-#endif
-
- /* Initialize interrupt handlers. */
- intr_init ();
- timer_init ();
- kbd_init ();
- input_init ();
-#ifdef USERPROG
- exception_init ();
- syscall_init ();
-#endif
-
- /* Start thread scheduler and enable interrupts. */
- thread_start ();
- serial_init_queue ();
- timer_calibrate ();
-
-#ifdef FILESYS
- /* Initialize file system. */
- ide_init ();
- locate_block_devices ();
- filesys_init (format_filesys);
-#endif
-
- printf ("Boot complete.\n");
-
- /* Run actions specified on kernel command line. */
- run_actions (argv);
-
- /* Finish up. */
- shutdown ();
- thread_exit ();
-}
-
-/* Clear the "BSS", a segment that should be initialized to
- zeros. It isn't actually stored on disk or zeroed by the
- kernel loader, so we have to zero it ourselves.
-
- The start and end of the BSS segment is recorded by the
- linker as _start_bss and _end_bss. See kernel.lds. */
-static void
-bss_init (void)
-{
- extern char _start_bss, _end_bss;
- memset (&_start_bss, 0, &_end_bss - &_start_bss);
-}
-
-/* Populates the base page directory and page table with the
- kernel virtual mapping, and then sets up the CPU to use the
- new page directory. Points init_page_dir to the page
- directory it creates. */
-static void
-paging_init (void)
-{
- uint32_t *pd, *pt;
- size_t page;
- extern char _start, _end_kernel_text;
-
- pd = init_page_dir = palloc_get_page (PAL_ASSERT | PAL_ZERO);
- pt = NULL;
- for (page = 0; page < init_ram_pages; page++)
- {
- uintptr_t paddr = page * PGSIZE;
- char *vaddr = ptov (paddr);
- size_t pde_idx = pd_no (vaddr);
- size_t pte_idx = pt_no (vaddr);
- bool in_kernel_text = &_start <= vaddr && vaddr < &_end_kernel_text;
-
- if (pd[pde_idx] == 0)
- {
- pt = palloc_get_page (PAL_ASSERT | PAL_ZERO);
- pd[pde_idx] = pde_create (pt);
- }
-
- pt[pte_idx] = pte_create_kernel (vaddr, !in_kernel_text);
- }
-
- /* Store the physical address of the page directory into CR3
- aka PDBR (page directory base register). This activates our
- new page tables immediately. See [IA32-v2a] "MOV--Move
- to/from Control Registers" and [IA32-v3a] 3.7.5 "Base Address
- of the Page Directory". */
- asm volatile ("movl %0, %%cr3" : : "r" (vtop (init_page_dir)));
-}
-
-/* Breaks the kernel command line into words and returns them as
- an argv-like array. */
-static char **
-read_command_line (void)
-{
- static char *argv[LOADER_ARGS_LEN / 2 + 1];
- char *p, *end;
- int argc;
- int i;
-
- argc = *(uint32_t *) ptov (LOADER_ARG_CNT);
- p = ptov (LOADER_ARGS);
- end = p + LOADER_ARGS_LEN;
- for (i = 0; i < argc; i++)
- {
- if (p >= end)
- PANIC ("command line arguments overflow");
-
- argv[i] = p;
- p += strnlen (p, end - p) + 1;
- }
- argv[argc] = NULL;
-
- /* Print kernel command line. */
- printf ("Kernel command line:");
- for (i = 0; i < argc; i++)
- if (strchr (argv[i], ' ') == NULL)
- printf (" %s", argv[i]);
- else
- printf (" '%s'", argv[i]);
- printf ("\n");
-
- return argv;
-}
-
-/* Parses options in ARGV[]
- and returns the first non-option argument. */
-static char **
-parse_options (char **argv)
-{
- for (; *argv != NULL && **argv == '-'; argv++)
- {
- char *save_ptr;
- char *name = strtok_r (*argv, "=", &save_ptr);
- char *value = strtok_r (NULL, "", &save_ptr);
-
- if (!strcmp (name, "-h"))
- usage ();
- else if (!strcmp (name, "-q"))
- shutdown_configure (SHUTDOWN_POWER_OFF);
- else if (!strcmp (name, "-r"))
- shutdown_configure (SHUTDOWN_REBOOT);
-#ifdef FILESYS
- else if (!strcmp (name, "-f"))
- format_filesys = true;
- else if (!strcmp (name, "-filesys"))
- filesys_bdev_name = value;
- else if (!strcmp (name, "-scratch"))
- scratch_bdev_name = value;
-#ifdef VM
- else if (!strcmp (name, "-swap"))
- swap_bdev_name = value;
-#endif
-#endif
- else if (!strcmp (name, "-rs"))
- random_init (atoi (value));
- else if (!strcmp (name, "-mlfqs"))
- thread_mlfqs = true;
-#ifdef USERPROG
- else if (!strcmp (name, "-ul"))
- user_page_limit = atoi (value);
-#endif
- else
- PANIC ("unknown option `%s' (use -h for help)", name);
- }
-
- /* Initialize the random number generator based on the system
- time. This has no effect if an "-rs" option was specified.
-
- When running under Bochs, this is not enough by itself to
- get a good seed value, because the pintos script sets the
- initial time to a predictable value, not to the local time,
- for reproducibility. To fix this, give the "-r" option to
- the pintos script to request real-time execution. */
- random_init (rtc_get_time ());
-
- return argv;
-}
-
-/* Runs the task specified in ARGV[1]. */
-static void
-run_task (char **argv)
-{
- const char *task = argv[1];
-
- printf ("Executing '%s':\n", task);
-#ifdef USERPROG
- process_wait (process_execute (task));
-#else
- run_test (task);
-#endif
- printf ("Execution of '%s' complete.\n", task);
-}
-
-/* Executes all of the actions specified in ARGV[]
- up to the null pointer sentinel. */
-static void
-run_actions (char **argv)
-{
- /* An action. */
- struct action
- {
- char *name; /* Action name. */
- int argc; /* # of args, including action name. */
- void (*function) (char **argv); /* Function to execute action. */
- };
-
- /* Table of supported actions. */
- static const struct action actions[] =
- {
- {"run", 2, run_task},
-#ifdef FILESYS
- {"ls", 1, fsutil_ls},
- {"cat", 2, fsutil_cat},
- {"rm", 2, fsutil_rm},
- {"extract", 1, fsutil_extract},
- {"append", 2, fsutil_append},
-#endif
- {NULL, 0, NULL},
- };
-
- while (*argv != NULL)
- {
- const struct action *a;
- int i;
-
- /* Find action name. */
- for (a = actions; ; a++)
- if (a->name == NULL)
- PANIC ("unknown action `%s' (use -h for help)", *argv);
- else if (!strcmp (*argv, a->name))
- break;
-
- /* Check for required arguments. */
- for (i = 1; i < a->argc; i++)
- if (argv[i] == NULL)
- PANIC ("action `%s' requires %d argument(s)", *argv, a->argc - 1);
-
- /* Invoke action and advance. */
- a->function (argv);
- argv += a->argc;
- }
-
-}
-
-/* Prints a kernel command line help message and powers off the
- machine. */
-static void
-usage (void)
-{
- printf ("\nCommand line syntax: [OPTION...] [ACTION...]\n"
- "Options must precede actions.\n"
- "Actions are executed in the order specified.\n"
- "\nAvailable actions:\n"
-#ifdef USERPROG
- " run 'PROG [ARG...]' Run PROG and wait for it to complete.\n"
-#else
- " run TEST Run TEST.\n"
-#endif
-#ifdef FILESYS
- " ls List files in the root directory.\n"
- " cat FILE Print FILE to the console.\n"
- " rm FILE Delete FILE.\n"
- "Use these actions indirectly via `pintos' -g and -p options:\n"
- " extract Untar from scratch device into file system.\n"
- " append FILE Append FILE to tar file on scratch device.\n"
-#endif
- "\nOptions:\n"
- " -h Print this help message and power off.\n"
- " -q Power off VM after actions or on panic.\n"
- " -r Reboot after actions.\n"
-#ifdef FILESYS
- " -f Format file system device during startup.\n"
- " -filesys=BDEV Use BDEV for file system instead of default.\n"
- " -scratch=BDEV Use BDEV for scratch instead of default.\n"
-#ifdef VM
- " -swap=BDEV Use BDEV for swap instead of default.\n"
-#endif
-#endif
- " -rs=SEED Set random number seed to SEED.\n"
- " -mlfqs Use multi-level feedback queue scheduler.\n"
-#ifdef USERPROG
- " -ul=COUNT Limit user memory to COUNT pages.\n"
-#endif
- );
- shutdown_power_off ();
-}
-
-#ifdef FILESYS
-/* Figure out what block devices to cast in the various Pintos roles. */
-static void
-locate_block_devices (void)
-{
- locate_block_device (BLOCK_FILESYS, filesys_bdev_name);
- locate_block_device (BLOCK_SCRATCH, scratch_bdev_name);
-#ifdef VM
- locate_block_device (BLOCK_SWAP, swap_bdev_name);
-#endif
-}
-
-/* Figures out what block device to use for the given ROLE: the
- block device with the given NAME, if NAME is non-null,
- otherwise the first block device in probe order of type
- ROLE. */
-static void
-locate_block_device (enum block_type role, const char *name)
-{
- struct block *block = NULL;
-
- if (name != NULL)
- {
- block = block_get_by_name (name);
- if (block == NULL)
- PANIC ("No such block device \"%s\"", name);
- }
- else
- {
- for (block = block_first (); block != NULL; block = block_next (block))
- if (block_type (block) == role)
- break;
- }
-
- if (block != NULL)
- {
- printf ("%s: using %s\n", block_type_name (role), block_name (block));
- block_set_role (role, block);
- }
-}
-#endif
View
12 src/devices/init.h
@@ -1,12 +0,0 @@
-#ifndef THREADS_INIT_H
-#define THREADS_INIT_H
-
-#include <debug.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-/* Page directory with kernel mappings only. */
-extern uint32_t *init_page_dir;
-
-#endif /* threads/init.h */
View
273 src/devices/timer.c~
@@ -1,273 +0,0 @@
-#include "devices/timer.h"
-#include <debug.h>
-#include <inttypes.h>
-#include <round.h>
-#include <stdio.h>
-#include "devices/pit.h"
-#include "threads/interrupt.h"
-#include "threads/synch.h"
-#include "threads/thread.h"
-
-/* See [8254] for hardware details of the 8254 timer chip. */
-
-#if TIMER_FREQ < 19
-#error 8254 timer requires TIMER_FREQ >= 19
-#endif
-#if TIMER_FREQ > 1000
-#error TIMER_FREQ <= 1000 recommended
-#endif
-
-/* Number of timer ticks since OS booted. */
-static int64_t ticks;
-
-/* Number of loops per timer tick.
- Initialized by timer_calibrate(). */
-static unsigned loops_per_tick;
-
-static intr_handler_func timer_interrupt;
-static bool too_many_loops (unsigned loops);
-static void busy_wait (int64_t loops);
-static void real_time_sleep (int64_t num, int32_t denom);
-static void real_time_delay (int64_t num, int32_t denom);
-static struct list thread_list;
-
-static bool compare_threads_by_wakeup_time(const struct list_elem *a_, const struct list_elem *b_, void *aux UNUSED)
-{
- const struct thread *a = list_entry(a_, struct thread, timer_list_elem);
- const struct thread *b = list_entry(b_, struct thread, timer_list_elem);
- return a->wakeup_time < b->wakeup_time;
-}
-
-/* Sets up the timer to interrupt TIMER_FREQ times per second,
- and registers the corresponding interrupt. */
-void
-timer_init (void)
-{
- pit_configure_channel (0, 2, TIMER_FREQ);
- intr_register_ext (0x20, timer_interrupt, "8254 Timer");
- list_init(&thread_list);
-}
-
-/* Calibrates loops_per_tick, used to implement brief delays. */
-void
-timer_calibrate (void)
-{
- unsigned high_bit, test_bit;
-
- ASSERT (intr_get_level () == INTR_ON);
- printf ("Calibrating timer... ");
-
- /* Approximate loops_per_tick as the largest power-of-two
- still less than one timer tick. */
- loops_per_tick = 1u << 10;
- while (!too_many_loops (loops_per_tick << 1))
- {
- loops_per_tick <<= 1;
- ASSERT (loops_per_tick != 0);
- }
-
- /* Refine the next 8 bits of loops_per_tick. */
- high_bit = loops_per_tick;
- for (test_bit = high_bit >> 1; test_bit != high_bit >> 10; test_bit >>= 1)
- if (!too_many_loops (high_bit | test_bit))
- loops_per_tick |= test_bit;
-
- printf ("%'"PRIu64" loops/s.\n", (uint64_t) loops_per_tick * TIMER_FREQ);
-}
-
-/* Returns the number of timer ticks since the OS booted. */
-int64_t
-timer_ticks (void)
-{
- enum intr_level old_level = intr_disable ();
- int64_t t = ticks;
- intr_set_level (old_level);
- return t;
-}
-
-/* Returns the number of timer ticks elapsed since THEN, which
- should be a value once returned by timer_ticks(). */
-int64_t
-timer_elapsed (int64_t then)
-{
- return timer_ticks () - then;
-}
-
-/* Sleeps for approximately TICKS timer ticks. Interrupts must
- be turned on. */
-void
-timer_sleep (int64_t ticks)
-{
-// printf("We got into sleep!\n");
- int64_t start = timer_ticks ();
- struct thread *t = thread_current();
- t->wakeup_time = ticks + start;
- intr_disable();
- list_insert_ordered(&thread_list, &t->timer_list_elem, compare_threads_by_wakeup_time,NULL);
- sema_down(&t->sema_wakeup);
- intr_enable();
-// printf("We got woken up\n");
- /*while (timer_elapsed (start) < ticks)
- thread_yield ();*/
-}
-
-/* Sleeps for approximately MS milliseconds. Interrupts must be
- turned on. */
-void
-timer_msleep (int64_t ms)
-{
- real_time_sleep (ms, 1000);
-}
-
-/* Sleeps for approximately US microseconds. Interrupts must be
- turned on. */
-void
-timer_usleep (int64_t us)
-{
- real_time_sleep (us, 1000 * 1000);
-}
-
-/* Sleeps for approximately NS nanoseconds. Interrupts must be
- turned on. */
-void
-timer_nsleep (int64_t ns)
-{
- real_time_sleep (ns, 1000 * 1000 * 1000);
-}
-
-/* Busy-waits for approximately MS milliseconds. Interrupts need
- not be turned on.
-
- Busy waiting wastes CPU cycles, and busy waiting with
- interrupts off for the interval between timer ticks or longer
- will cause timer ticks to be lost. Thus, use timer_msleep()
- instead if interrupts are enabled. */
-void
-timer_mdelay (int64_t ms)
-{
- real_time_delay (ms, 1000);
-}
-
-/* Sleeps for approximately US microseconds. Interrupts need not
- be turned on.
-
- Busy waiting wastes CPU cycles, and busy waiting with
- interrupts off for the interval between timer ticks or longer
- will cause timer ticks to be lost. Thus, use timer_usleep()
- instead if interrupts are enabled. */
-void
-timer_udelay (int64_t us)
-{
- real_time_delay (us, 1000 * 1000);
-}
-
-/* Sleeps execution for approximately NS nanoseconds. Interrupts
- need not be turned on.
-
- Busy waiting wastes CPU cycles, and busy waiting with
- interrupts off for the interval between timer ticks or longer
- will cause timer ticks to be lost. Thus, use timer_nsleep()
- instead if interrupts are enabled.*/
-void
-timer_ndelay (int64_t ns)
-{
- real_time_delay (ns, 1000 * 1000 * 1000);
-}
-
-/* Prints timer statistics. */
-void
-timer_print_stats (void)
-{
- printf ("Timer: %"PRId64" ticks\n", timer_ticks ());
-}
-
-/* Timer interrupt handler. */
-static void
-timer_interrupt (struct intr_frame *args UNUSED)
-{
- ticks++;
- thread_tick ();
- //printf("Interupting\n");
- //Check to see if first element in list is ready to start
- while (!list_empty(&thread_list))
- {
- struct thread *head = list_entry(list_front(&thread_list),struct thread, timer_list_elem);
- if (ticks < head->wakeup_time) break;
- sema_up(&head->sema_wakeup);
- //thread_yield();
- list_pop_front(&thread_list);
- }
-}
-
-/* Returns true if LOOPS iterations waits for more than one timer
- tick, otherwise false. */
-static bool
-too_many_loops (unsigned loops)
-{
- /* Wait for a timer tick. */
- int64_t start = ticks;
- while (ticks == start)
- barrier ();
-
- /* Run LOOPS loops. */
- start = ticks;
- busy_wait (loops);
-
- /* If the tick count changed, we iterated too long. */
- barrier ();
- return start != ticks;
-}
-
-/* Iterates through a simple loop LOOPS times, for implementing
- brief delays.
-
- Marked NO_INLINE because code alignment can significantly
- affect timings, so that if this function was inlined
- differently in different places the results would be difficult
- to predict. */
-static void NO_INLINE
-busy_wait (int64_t loops)
-{
- while (loops-- > 0)
- barrier ();
-}
-
-/* Sleep for approximately NUM/DENOM seconds. */
-static void
-real_time_sleep (int64_t num, int32_t denom)
-{
- /* Convert NUM/DENOM seconds into timer ticks, rounding down.
-
- (NUM / DENOM) s
- ---------------------- = NUM * TIMER_FREQ / DENOM ticks.
- 1 s / TIMER_FREQ ticks
- */
- int64_t ticks = num * TIMER_FREQ / denom;
-
- ASSERT (intr_get_level () == INTR_ON);
- if (ticks > 0)
- {
- /* We're waiting for at least one full timer tick. Use
- timer_sleep() because it will yield the CPU to other
- processes. */
- timer_sleep (ticks);
- }
- else
- {
- /* Otherwise, use a busy-wait loop for more accurate
- sub-tick timing. */
- real_time_delay (num, denom);
- }
-}
-
-
-
-/* Busy-wait for approximately NUM/DENOM seconds. */
-static void
-real_time_delay (int64_t num, int32_t denom)
-{
- /* Scale the numerator and denominator down by 1000 to avoid
- the possibility of overflow. */
- ASSERT (denom % 1000 == 0);
- busy_wait (loops_per_tick * num / 1000 * TIMER_FREQ / (denom / 1000));
-}
View
31 src/devices/timer.h~
@@ -1,31 +0,0 @@
-#ifndef DEVICES_TIMER_H
-#define DEVICES_TIMER_H
-#include <stdbool.h>
-#include <round.h>
-#include <stdint.h>
-#include <list.h>
-/* Number of timer interrupts per second. */
-#define TIMER_FREQ 100
-
-void timer_init (void);
-void timer_calibrate (void);
-
-int64_t timer_ticks (void);
-int64_t timer_elapsed (int64_t);
-
-/* Sleep and yield the CPU to other threads. */
-void timer_sleep (int64_t ticks);
-void timer_msleep (int64_t milliseconds);
-void timer_usleep (int64_t microseconds);
-void timer_nsleep (int64_t nanoseconds);
-
-/* Busy waits. */
-void timer_mdelay (int64_t milliseconds);
-void timer_udelay (int64_t microseconds);
-void timer_ndelay (int64_t nanoseconds);
-
-void timer_print_stats (void);
-bool compare_threads_by_wakeup_time(struct list_elem *a_, struct list_elem *b_, void *aux);
-
-
-#endif /* devices/timer.h */
View
53 src/log-multiple.txt
@@ -1,53 +0,0 @@
-PiLo hda1
-Loading..........
-Kernel command line: run alarm-multiple========================================================================
- Bochs x86 Emulator 2.4.5
- Build from CVS snapshot, on April 25, 2010
-========================================================================
-to sleep 7 times each.
-(alarm-multiple) Thread 0 sleeps 10 ticks each time,
-(alarm-multiple) thread 1 sleeps 20 ticks each time, and so on.
-(alarm-multiple) If successful, product of iteration count and
-(alarm-multiple) sleep duration will appear in nondescending order.
-(alarm-multiple) thread 0: duration=10, iteration=1, product=10
-(alarm-multiple) thread 0: duration=10, iteration=2, product=20
-(alarm-multiple) thread 1: duration=20, iteration=1, product=20
-(alarm-multiple) thread 2: duration=30, iteration=1, product=30
-(alarm-multiple) thread 0: duration=10, iteration=3, product=30
-(alarm-multiple) thread 3: duration=40, iteration=1, product=40
-(alarm-multiple) thread 0: duration=10, iteration=4, product=40
-(alarm-multiple) thread 1: duration=20, iteration=2, product=40
-(alarm-multiple) thread 4: duration=50, iteration=1, product=50
-(alarm-multiple) thread 0: duration=10, iteration=5, product=50
-(alarm-multiple) thread 1: duration=20, iteration=3, product=60
-(alarm-multiple) thread 2: duration=30, iteration=2, product=60
-(alarm-multiple) thread 0: duration=10, iteration=6, product=60
-(alarm-multiple) thread 0: duration=10, iteration=7, product=70
-(alarm-multiple) thread 1: duration=20, iteration=4, product=80
-(alarm-multiple) thread 3: duration=40, iteration=2, product=80
-(alarm-multiple) thread 2: duration=30, iteration=3, product=90
-(alarm-multiple) thread 4: duration=50, iteration=2, product=100
-(alarm-multiple) thread 1: duration=20, iteration=5, product=100
-(alarm-multiple) thread 2: duration=30, iteration=4, product=120
-(alarm-multiple) thread 3: duration=40, iteration=3, product=120
-(alarm-multiple) thread 1: duration=20, iteration=6, product=120
-(alarm-multiple) thread 1: duration=20, iteration=7, product=140
-(alarm-multiple) thread 4: duration=50, iteration=3, product=150
-(alarm-multiple) thread 2: duration=30, iteration=5, product=150
-(alarm-multiple) thread 3: duration=40, iteration=4, product=160
-(alarm-multiple) thread 2: duration=30, iteration=6, product=180
-(alarm-multiple) thread 3: duration=40, iteration=5, product=200
-(alarm-multiple) thread 4: duration=50, iteration=4, product=200
-(alarm-multiple) thread 2: duration=30, iteration=7, product=210
-(alarm-multiple) thread 3: duration=40, iteration=6, product=240
-(alarm-multiple) thread 4: duration=50, iteration=5, product=250
-(alarm-multiple) thread 3: duration=40, iteration=7, product=280
-(alarm-multiple) thread 4: duration=50, iteration=6, product=300
-(alarm-multiple) thread 4: duration=50, iteration=7, product=350
-(alarm-multiple) end
-Execution of 'alarm-multiple' complete.
-Kernel PANIC at ../../threads/init.c:330 in run_actions(): unknown action `-x' (use -h for help)
-Call stack: 0xc00283de.
-The `backtrace' program can make call stacks useful.
-Read "Backtraces" in the "Debugging Tools" chapter
-of the Pintos documentation for more information.
View
22 src/threads/README.txt
@@ -1,22 +0,0 @@
-Grant Borthwick
-CIS 520
-Project 0
-
-To implement alarm-nega, I had to do three things.
-
-1. add alarm-mega.ck which is an exact copy of alarm-multiple with check_alarm (70); instead of check_alarm (7);
-
-2. Add {"alarm-mega", test_alarm_mega}, into tests.c
-
-3. Add extern test_func test_alarm_mega; into tests.h
-
-4. Add alarm-mega to the list of test names in Make.tests
-
-5. Add
-void
-test_alarm_mega (void)
-{
- test_sleep (5, 70);
-}
-
-into alarm-wait.c
View
364 src/threads/log-mega.txt
@@ -1,364 +0,0 @@
-PiLo hda1
-Loading..........
-Kernel command line: run alarm-mega
-Pin========================================================================
- Bochs x86 Emulator 2.4.5
- Build from CVS snapshot, on April 25, 2010
-========================================================================
-ach.
-(alarm-mega) Thread 0 sleeps 10 ticks each time,
-(alarm-mega) thread 1 sleeps 20 ticks each time, and so on.
-(alarm-mega) If successful, product of iteration count and
-(alarm-mega) sleep duration will appear in nondescending order.
-(alarm-mega) thread 0: duration=10, iteration=1, product=10
-(alarm-mega) thread 0: duration=10, iteration=2, product=20
-(alarm-mega) thread 1: duration=20, iteration=1, product=20
-(alarm-mega) thread 0: duration=10, iteration=3, product=30
-(alarm-mega) thread 2: duration=30, iteration=1, product=30
-(alarm-mega) thread 3: duration=40, iteration=1, product=40
-(alarm-mega) thread 0: duration=10, iteration=4, product=40
-(alarm-mega) thread 1: duration=20, iteration=2, product=40
-(alarm-mega) thread 4: duration=50, iteration=1, product=50
-(alarm-mega) thread 0: duration=10, iteration=5, product=50
-(alarm-mega) thread 0: duration=10, iteration=6, product=60
-(alarm-mega) thread 1: duration=20, iteration=3, product=60
-(alarm-mega) thread 2: duration=30, iteration=2, product=60
-(alarm-mega) thread 0: duration=10, iteration=7, product=70
-(alarm-mega) thread 0: duration=10, iteration=8, product=80
-(alarm-mega) thread 1: duration=20, iteration=4, product=80
-(alarm-mega) thread 3: duration=40, iteration=2, product=80
-(alarm-mega) thread 0: duration=10, iteration=9, product=90
-(alarm-mega) thread 2: duration=30, iteration=3, product=90
-(alarm-mega) thread 4: duration=50, iteration=2, product=100
-(alarm-mega) thread 0: duration=10, iteration=10, product=100
-(alarm-mega) thread 1: duration=20, iteration=5, product=100
-(alarm-mega) thread 0: duration=10, iteration=11, product=110
-(alarm-mega) thread 0: duration=10, iteration=12, product=120
-(alarm-mega) thread 1: duration=20, iteration=6, product=120
-(alarm-mega) thread 2: duration=30, iteration=4, product=120
-(alarm-mega) thread 3: duration=40, iteration=3, product=120
-(alarm-mega) thread 0: duration=10, iteration=13, product=130
-(alarm-mega) thread 0: duration=10, iteration=14, product=140
-(alarm-mega) thread 1: duration=20, iteration=7, product=140
-(alarm-mega) thread 0: duration=10, iteration=15, product=150
-(alarm-mega) thread 2: duration=30, iteration=5, product=150
-(alarm-mega) thread 4: duration=50, iteration=3, product=150
-(alarm-mega) thread 3: duration=40, iteration=4, product=160
-(alarm-mega) thread 0: duration=10, iteration=16, product=160
-(alarm-mega) thread 1: duration=20, iteration=8, product=160
-(alarm-mega) thread 0: duration=10, iteration=17, product=170
-(alarm-mega) thread 0: duration=10, iteration=18, product=180
-(alarm-mega) thread 1: duration=20, iteration=9, product=180
-(alarm-mega) thread 2: duration=30, iteration=6, product=180
-(alarm-mega) thread 0: duration=10, iteration=19, product=190
-(alarm-mega) thread 0: duration=10, iteration=20, product=200
-(alarm-mega) thread 1: duration=20, iteration=10, product=200
-(alarm-mega) thread 3: duration=40, iteration=5, product=200
-(alarm-mega) thread 4: duration=50, iteration=4, product=200
-(alarm-mega) thread 0: duration=10, iteration=21, product=210
-(alarm-mega) thread 2: duration=30, iteration=7, product=210
-(alarm-mega) thread 0: duration=10, iteration=22, product=220
-(alarm-mega) thread 1: duration=20, iteration=11, product=220
-(alarm-mega) thread 0: duration=10, iteration=23, product=230
-(alarm-mega) thread 2: duration=30, iteration=8, product=240
-(alarm-mega) thread 3: duration=40, iteration=6, product=240
-(alarm-mega) thread 0: duration=10, iteration=24, product=240
-(alarm-mega) thread 1: duration=20, iteration=12, product=240
-(alarm-mega) thread 4: duration=50, iteration=5, product=250
-(alarm-mega) thread 0: duration=10, iteration=25, product=250
-(alarm-mega) thread 0: duration=10, iteration=26, product=260
-(alarm-mega) thread 1: duration=20, iteration=13, product=260
-(alarm-mega) thread 0: duration=10, iteration=27, product=270
-(alarm-mega) thread 2: duration=30, iteration=9, product=270
-(alarm-mega) thread 3: duration=40, iteration=7, product=280
-(alarm-mega) thread 0: duration=10, iteration=28, product=280
-(alarm-mega) thread 1: duration=20, iteration=14, product=280
-(alarm-mega) thread 0: duration=10, iteration=29, product=290
-(alarm-mega) thread 2: duration=30, iteration=10, product=300
-(alarm-mega) thread 4: duration=50, iteration=6, product=300
-(alarm-mega) thread 0: duration=10, iteration=30, product=300
-(alarm-mega) thread 1: duration=20, iteration=15, product=300
-(alarm-mega) thread 0: duration=10, iteration=31, product=310
-(alarm-mega) thread 0: duration=10, iteration=32, product=320
-(alarm-mega) thread 1: duration=20, iteration=16, product=320
-(alarm-mega) thread 3: duration=40, iteration=8, product=320
-(alarm-mega) thread 0: duration=10, iteration=33, product=330
-(alarm-mega) thread 2: duration=30, iteration=11, product=330
-(alarm-mega) thread 0: duration=10, iteration=34, product=340
-(alarm-mega) thread 1: duration=20, iteration=17, product=340
-(alarm-mega) thread 0: duration=10, iteration=35, product=350
-(alarm-mega) thread 4: duration=50, iteration=7, product=350
-(alarm-mega) thread 2: duration=30, iteration=12, product=360
-(alarm-mega) thread 3: duration=40, iteration=9, product=360
-(alarm-mega) thread 0: duration=10, iteration=36, product=360
-(alarm-mega) thread 1: duration=20, iteration=18, product=360
-(alarm-mega) thread 0: duration=10, iteration=37, product=370
-(alarm-mega) thread 0: duration=10, iteration=38, product=380
-(alarm-mega) thread 1: duration=20, iteration=19, product=380
-(alarm-mega) thread 2: duration=30, iteration=13, product=390
-(alarm-mega) thread 0: duration=10, iteration=39, product=390
-(alarm-mega) thread 4: duration=50, iteration=8, product=400
-(alarm-mega) thread 0: duration=10, iteration=40, product=400
-(alarm-mega) thread 1: duration=20, iteration=20, product=400
-(alarm-mega) thread 3: duration=40, iteration=10, product=400
-(alarm-mega) thread 0: duration=10, iteration=41, product=410
-(alarm-mega) thread 2: duration=30, iteration=14, product=420
-(alarm-mega) thread 0: duration=10, iteration=42, product=420
-(alarm-mega) thread 1: duration=20, iteration=21, product=420
-(alarm-mega) thread 0: duration=10, iteration=43, product=430
-(alarm-mega) thread 0: duration=10, iteration=44, product=440
-(alarm-mega) thread 1: duration=20, iteration=22, product=440
-(alarm-mega) thread 3: duration=40, iteration=11, product=440
-(alarm-mega) thread 2: duration=30, iteration=15, product=450
-(alarm-mega) thread 4: duration=50, iteration=9, product=450
-(alarm-mega) thread 0: duration=10, iteration=45, product=450
-(alarm-mega) thread 0: duration=10, iteration=46, product=460
-(alarm-mega) thread 1: duration=20, iteration=23, product=460
-(alarm-mega) thread 0: duration=10, iteration=47, product=470
-(alarm-mega) thread 3: duration=40, iteration=12, product=480
-(alarm-mega) thread 0: duration=10, iteration=48, product=480
-(alarm-mega) thread 1: duration=20, iteration=24, product=480
-(alarm-mega) thread 2: duration=30, iteration=16, product=480
-(alarm-mega) thread 0: duration=10, iteration=49, product=490
-(alarm-mega) thread 0: duration=10, iteration=50, product=500
-(alarm-mega) thread 1: duration=20, iteration=25, product=500
-(alarm-mega) thread 4: duration=50, iteration=10, product=500
-(alarm-mega) thread 2: duration=30, iteration=17, product=510
-(alarm-mega) thread 0: duration=10, iteration=51, product=510
-(alarm-mega) thread 0: duration=10, iteration=52, product=520
-(alarm-mega) thread 1: duration=20, iteration=26, product=520
-(alarm-mega) thread 3: duration=40, iteration=13, product=520
-(alarm-mega) thread 0: duration=10, iteration=53, product=530
-(alarm-mega) thread 0: duration=10, iteration=54, product=540
-(alarm-mega) thread 1: duration=20, iteration=27, product=540
-(alarm-mega) thread 2: duration=30, iteration=18, product=540
-(alarm-mega) thread 4: duration=50, iteration=11, product=550
-(alarm-mega) thread 0: duration=10, iteration=55, product=550
-(alarm-mega) thread 0: duration=10, iteration=56, product=560
-(alarm-mega) thread 1: duration=20, iteration=28, product=560
-(alarm-mega) thread 3: duration=40, iteration=14, product=560
-(alarm-mega) thread 2: duration=30, iteration=19, product=570
-(alarm-mega) thread 0: duration=10, iteration=57, product=570
-(alarm-mega) thread 0: duration=10, iteration=58, product=580
-(alarm-mega) thread 1: duration=20, iteration=29, product=580
-(alarm-mega) thread 0: duration=10, iteration=59, product=590
-(alarm-mega) thread 4: duration=50, iteration=12, product=600
-(alarm-mega) thread 0: duration=10, iteration=60, product=600
-(alarm-mega) thread 1: duration=20, iteration=30, product=600
-(alarm-mega) thread 2: duration=30, iteration=20, product=600
-(alarm-mega) thread 3: duration=40, iteration=15, product=600
-(alarm-mega) thread 0: duration=10, iteration=61, product=610
-(alarm-mega) thread 0: duration=10, iteration=62, product=620
-(alarm-mega) thread 1: duration=20, iteration=31, product=620
-(alarm-mega) thread 0: duration=10, iteration=63, product=630
-(alarm-mega) thread 2: duration=30, iteration=21, product=630
-(alarm-mega) thread 0: duration=10, iteration=64, product=640
-(alarm-mega) thread 1: duration=20, iteration=32, product=640
-(alarm-mega) thread 3: duration=40, iteration=16, product=640
-(alarm-mega) thread 0: duration=10, iteration=65, product=650
-(alarm-mega) thread 4: duration=50, iteration=13, product=650
-(alarm-mega) thread 0: duration=10, iteration=66, product=660
-(alarm-mega) thread 1: duration=20, iteration=33, product=660
-(alarm-mega) thread 2: duration=30, iteration=22, product=660
-(alarm-mega) thread 0: duration=10, iteration=67, product=670
-(alarm-mega) thread 3: duration=40, iteration=17, product=680
-(alarm-mega) thread 0: duration=10, iteration=68, product=680
-(alarm-mega) thread 1: duration=20, iteration=34, product=680
-(alarm-mega) thread 0: duration=10, iteration=69, product=690
-(alarm-mega) thread 2: duration=30, iteration=23, product=690
-(alarm-mega) thread 0: duration=10, iteration=70, product=700
-(alarm-mega) thread 1: duration=20, iteration=35, product=700
-(alarm-mega) thread 4: duration=50, iteration=14, product=700
-(alarm-mega) thread 1: duration=20, iteration=36, product=720
-(alarm-mega) thread 2: duration=30, iteration=24, product=720
-(alarm-mega) thread 3: duration=40, iteration=18, product=720
-(alarm-mega) thread 1: duration=20, iteration=37, product=740
-(alarm-mega) thread 4: duration=50, iteration=15, product=750
-(alarm-mega) thread 2: duration=30, iteration=25, product=750
-(alarm-mega) thread 3: duration=40, iteration=19, product=760
-(alarm-mega) thread 1: duration=20, iteration=38, product=760
-(alarm-mega) thread 2: duration=30, iteration=26, product=780
-(alarm-mega) thread 1: duration=20, iteration=39, product=780
-(alarm-mega) thread 1: duration=20, iteration=40, product=800
-(alarm-mega) thread 3: duration=40, iteration=20, product=800
-(alarm-mega) thread 4: duration=50, iteration=16, product=800
-(alarm-mega) thread 2: duration=30, iteration=27, product=810
-(alarm-mega) thread 1: duration=20, iteration=41, product=820
-(alarm-mega) thread 1: duration=20, iteration=42, product=840
-(alarm-mega) thread 2: duration=30, iteration=28, product=840
-(alarm-mega) thread 3: duration=40, iteration=21, product=840
-(alarm-mega) thread 4: duration=50, iteration=17, product=850
-(alarm-mega) thread 1: duration=20, iteration=43, product=860
-(alarm-mega) thread 2: duration=30, iteration=29, product=870
-(alarm-mega) thread 1: duration=20, iteration=44, product=880
-(alarm-mega) thread 3: duration=40, iteration=22, product=880
-(alarm-mega) thread 1: duration=20, iteration=45, product=900
-(alarm-mega) thread 2: duration=30, iteration=30, product=900
-(alarm-mega) thread 4: duration=50, iteration=18, product=900
-(alarm-mega) thread 3: duration=40, iteration=23, product=920
-(alarm-mega) thread 1: duration=20, iteration=46, product=920
-(alarm-mega) thread 2: duration=30, iteration=31, product=930
-(alarm-mega) thread 1: duration=20, iteration=47, product=940
-(alarm-mega) thread 4: duration=50, iteration=19, product=950
-(alarm-mega) thread 1: duration=20, iteration=48, product=960
-(alarm-mega) thread 2: duration=30, iteration=32, product=960
-(alarm-mega) thread 3: duration=40, iteration=24, product=960
-(alarm-mega) thread 1: duration=20, iteration=49, product=980
-(alarm-mega) thread 2: duration=30, iteration=33, product=990
-(alarm-mega) thread 3: duration=40, iteration=25, product=1000
-(alarm-mega) thread 4: duration=50, iteration=20, product=1000
-(alarm-mega) thread 1: duration=20, iteration=50, product=1000
-(alarm-mega) thread 2: duration=30, iteration=34, product=1020
-(alarm-mega) thread 1: duration=20, iteration=51, product=1020
-(alarm-mega) thread 1: duration=20, iteration=52, product=1040
-(alarm-mega) thread 3: duration=40, iteration=26, product=1040
-(alarm-mega) thread 2: duration=30, iteration=35, product=1050
-(alarm-mega) thread 4: duration=50, iteration=21, product=1050
-(alarm-mega) thread 1: duration=20, iteration=53, product=1060
-(alarm-mega) thread 1: duration=20, iteration=54, product=1080
-(alarm-mega) thread 2: duration=30, iteration=36, product=1080
-(alarm-mega) thread 3: duration=40, iteration=27, product=1080
-(alarm-mega) thread 4: duration=50, iteration=22, product=1100
-(alarm-mega) thread 1: duration=20, iteration=55, product=1100
-(alarm-mega) thread 2: duration=30, iteration=37, product=1110
-(alarm-mega) thread 1: duration=20, iteration=56, product=1120
-(alarm-mega) thread 3: duration=40, iteration=28, product=1120
-(alarm-mega) thread 1: duration=20, iteration=57, product=1140
-(alarm-mega) thread 2: duration=30, iteration=38, product=1140
-(alarm-mega) thread 4: duration=50, iteration=23, product=1150
-(alarm-mega) thread 3: duration=40, iteration=29, product=1160
-(alarm-mega) thread 1: duration=20, iteration=58, product=1160
-(alarm-mega) thread 2: duration=30, iteration=39, product=1170
-(alarm-mega) thread 1: duration=20, iteration=59, product=1180
-(alarm-mega) thread 2: duration=30, iteration=40, product=1200
-(alarm-mega) thread 3: duration=40, iteration=30, product=1200
-(alarm-mega) thread 4: duration=50, iteration=24, product=1200
-(alarm-mega) thread 1: duration=20, iteration=60, product=1200
-(alarm-mega) thread 1: duration=20, iteration=61, product=1220
-(alarm-mega) thread 2: duration=30, iteration=41, product=1230
-(alarm-mega) thread 1: duration=20, iteration=62, product=1240
-(alarm-mega) thread 3: duration=40, iteration=31, product=1240
-(alarm-mega) thread 4: duration=50, iteration=25, product=1250
-(alarm-mega) thread 2: duration=30, iteration=42, product=1260
-(alarm-mega) thread 1: duration=20, iteration=63, product=1260
-(alarm-mega) thread 1: duration=20, iteration=64, product=1280
-(alarm-mega) thread 3: duration=40, iteration=32, product=1280
-(alarm-mega) thread 2: duration=30, iteration=43, product=1290
-(alarm-mega) thread 1: duration=20, iteration=65, product=1300
-(alarm-mega) thread 4: duration=50, iteration=26, product=1300
-(alarm-mega) thread 1: duration=20, iteration=66, product=1320
-(alarm-mega) thread 2: duration=30, iteration=44, product=1320
-(alarm-mega) thread 3: duration=40, iteration=33, product=1320
-(alarm-mega) thread 1: duration=20, iteration=67, product=1340
-(alarm-mega) thread 2: duration=30, iteration=45, product=1350
-(alarm-mega) thread 4: duration=50, iteration=27, product=1350
-(alarm-mega) thread 1: duration=20, iteration=68, product=1360
-(alarm-mega) thread 3: duration=40, iteration=34, product=1360
-(alarm-mega) thread 1: duration=20, iteration=69, product=1380
-(alarm-mega) thread 2: duration=30, iteration=46, product=1380
-(alarm-mega) thread 1: duration=20, iteration=70, product=1400
-(alarm-mega) thread 3: duration=40, iteration=35, product=1400
-(alarm-mega) thread 4: duration=50, iteration=28, product=1400
-(alarm-mega) thread 2: duration=30, iteration=47, product=1410
-(alarm-mega) thread 2: duration=30, iteration=48, product=1440
-(alarm-mega) thread 3: duration=40, iteration=36, product=1440
-(alarm-mega) thread 4: duration=50, iteration=29, product=1450
-(alarm-mega) thread 2: duration=30, iteration=49, product=1470
-(alarm-mega) thread 3: duration=40, iteration=37, product=1480
-(alarm-mega) thread 2: duration=30, iteration=50, product=1500
-(alarm-mega) thread 4: duration=50, iteration=30, product=1500
-(alarm-mega) thread 3: duration=40, iteration=38, product=1520
-(alarm-mega) thread 2: duration=30, iteration=51, product=1530
-(alarm-mega) thread 4: duration=50, iteration=31, product=1550
-(alarm-mega) thread 2: duration=30, iteration=52, product=1560
-(alarm-mega) thread 3: duration=40, iteration=39, product=1560
-(alarm-mega) thread 2: duration=30, iteration=53, product=1590
-(alarm-mega) thread 3: duration=40, iteration=40, product=1600
-(alarm-mega) thread 4: duration=50, iteration=32, product=1600
-(alarm-mega) thread 2: duration=30, iteration=54, product=1620
-(alarm-mega) thread 3: duration=40, iteration=41, product=1640
-(alarm-mega) thread 4: duration=50, iteration=33, product=1650
-(alarm-mega) thread 2: duration=30, iteration=55, product=1650
-(alarm-mega) thread 2: duration=30, iteration=56, product=1680
-(alarm-mega) thread 3: duration=40, iteration=42, product=1680
-(alarm-mega) thread 4: duration=50, iteration=34, product=1700
-(alarm-mega) thread 2: duration=30, iteration=57, product=1710
-(alarm-mega) thread 3: duration=40, iteration=43, product=1720
-(alarm-mega) thread 2: duration=30, iteration=58, product=1740
-(alarm-mega) thread 4: duration=50, iteration=35, product=1750
-(alarm-mega) thread 3: duration=40, iteration=44, product=1760
-(alarm-mega) thread 2: duration=30, iteration=59, product=1770
-(alarm-mega) thread 3: duration=40, iteration=45, product=1800
-(alarm-mega) thread 4: duration=50, iteration=36, product=1800
-(alarm-mega) thread 2: duration=30, iteration=60, product=1800
-(alarm-mega) thread 2: duration=30, iteration=61, product=1830
-(alarm-mega) thread 3: duration=40, iteration=46, product=1840
-(alarm-mega) thread 4: duration=50, iteration=37, product=1850
-(alarm-mega) thread 2: duration=30, iteration=62, product=1860
-(alarm-mega) thread 3: duration=40, iteration=47, product=1880
-(alarm-mega) thread 2: duration=30, iteration=63, product=1890
-(alarm-mega) thread 4: duration=50, iteration=38, product=1900
-(alarm-mega) thread 3: duration=40, iteration=48, product=1920
-(alarm-mega) thread 2: duration=30, iteration=64, product=1920
-(alarm-mega) thread 2: duration=30, iteration=65, product=1950
-(alarm-mega) thread 4: duration=50, iteration=39, product=1950
-(alarm-mega) thread 3: duration=40, iteration=49, product=1960
-(alarm-mega) thread 2: duration=30, iteration=66, product=1980
-(alarm-mega) thread 4: duration=50, iteration=40, product=2000
-(alarm-mega) thread 3: duration=40, iteration=50, product=2000
-(alarm-mega) thread 2: duration=30, iteration=67, product=2010
-(alarm-mega) thread 2: duration=30, iteration=68, product=2040
-(alarm-mega) thread 3: duration=40, iteration=51, product=2040
-(alarm-mega) thread 4: duration=50, iteration=41, product=2050
-(alarm-mega) thread 2: duration=30, iteration=69, product=2070
-(alarm-mega) thread 3: duration=40, iteration=52, product=2080
-(alarm-mega) thread 4: duration=50, iteration=42, product=2100
-(alarm-mega) thread 2: duration=30, iteration=70, product=2100
-(alarm-mega) thread 3: duration=40, iteration=53, product=2120
-(alarm-mega) thread 4: duration=50, iteration=43, product=2150
-(alarm-mega) thread 3: duration=40, iteration=54, product=2160
-(alarm-mega) thread 3: duration=40, iteration=55, product=2200
-(alarm-mega) thread 4: duration=50, iteration=44, product=2200
-(alarm-mega) thread 3: duration=40, iteration=56, product=2240
-(alarm-mega) thread 4: duration=50, iteration=45, product=2250
-(alarm-mega) thread 3: duration=40, iteration=57, product=2280
-(alarm-mega) thread 4: duration=50, iteration=46, product=2300
-(alarm-mega) thread 3: duration=40, iteration=58, product=2320
-(alarm-mega) thread 4: duration=50, iteration=47, product=2350
-(alarm-mega) thread 3: duration=40, iteration=59, product=2360
-(alarm-mega) thread 3: duration=40, iteration=60, product=2400
-(alarm-mega) thread 4: duration=50, iteration=48, product=2400
-(alarm-mega) thread 3: duration=40, iteration=61, product=2440
-(alarm-mega) thread 4: duration=50, iteration=49, product=2450
-(alarm-mega) thread 3: duration=40, iteration=62, product=2480
-(alarm-mega) thread 4: duration=50, iteration=50, product=2500
-(alarm-mega) thread 3: duration=40, iteration=63, product=2520
-(alarm-mega) thread 4: duration=50, iteration=51, product=2550
-(alarm-mega) thread 3: duration=40, iteration=64, product=2560
-(alarm-mega) thread 3: duration=40, iteration=65, product=2600
-(alarm-mega) thread 4: duration=50, iteration=52, product=2600
-(alarm-mega) thread 3: duration=40, iteration=66, product=2640
-(alarm-mega) thread 4: duration=50, iteration=53, product=2650
-(alarm-mega) thread 3: duration=40, iteration=67, product=2680
-(alarm-mega) thread 4: duration=50, iteration=54, product=2700
-(alarm-mega) thread 3: duration=40, iteration=68, product=2720
-(alarm-mega) thread 4: duration=50, iteration=55, product=2750
-(alarm-mega) thread 3: duration=40, iteration=69, product=2760
-(alarm-mega) thread 3: duration=40, iteration=70, product=2800
-(alarm-mega) thread 4: duration=50, iteration=56, product=2800
-(alarm-mega) thread 4: duration=50, iteration=57, product=2850
-(alarm-mega) thread 4: duration=50, iteration=58, product=2900
-(alarm-mega) thread 4: duration=50, iteration=59, product=2950
-(alarm-mega) thread 4: duration=50, iteration=60, product=3000
-(alarm-mega) thread 4: duration=50, iteration=61, product=3050
-(alarm-mega) thread 4: duration=50, iteration=62, product=3100
-(alarm-mega) thread 4: duration=50, iteration=63, product=3150
-(alarm-mega) thread 4: duration=50, iteration=64, product=3200
-(alarm-mega) thread 4: duration=50, iteration=65, product=3250
-(alarm-mega) thread 4: duration=50, iteration=66, product=3300
-(alarm-mega) thread 4: duration=50, iteration=67, product=3350
-(alarm-mega) thread 4: duration=50, iteration=68, product=3400
-(alarm-mega) thread 4: duration=50, iteration=69, product=3450
-(alarm-mega) thread 4: duration=50, iteration=70, product=3500
-(alarm-mega) end
-Execution of 'alarm-mega' complete.
View
53 src/threads/log-multiple.txt
@@ -1,53 +0,0 @@
-PiLo hda1
-Loading..........
-Kernel command line: run alarm-multiple========================================================================
- Bochs x86 Emulator 2.4.5
- Build from CVS snapshot, on April 25, 2010
-========================================================================
-to sleep 7 times each.
-(alarm-multiple) Thread 0 sleeps 10 ticks each time,
-(alarm-multiple) thread 1 sleeps 20 ticks each time, and so on.
-(alarm-multiple) If successful, product of iteration count and
-(alarm-multiple) sleep duration will appear in nondescending order.
-(alarm-multiple) thread 0: duration=10, iteration=1, product=10
-(alarm-multiple) thread 0: duration=10, iteration=2, product=20
-(alarm-multiple) thread 1: duration=20, iteration=1, product=20
-(alarm-multiple) thread 2: duration=30, iteration=1, product=30
-(alarm-multiple) thread 0: duration=10, iteration=3, product=30
-(alarm-multiple) thread 3: duration=40, iteration=1, product=40
-(alarm-multiple) thread 0: duration=10, iteration=4, product=40
-(alarm-multiple) thread 1: duration=20, iteration=2, product=40
-(alarm-multiple) thread 4: duration=50, iteration=1, product=50
-(alarm-multiple) thread 0: duration=10, iteration=5, product=50
-(alarm-multiple) thread 1: duration=20, iteration=3, product=60
-(alarm-multiple) thread 2: duration=30, iteration=2, product=60
-(alarm-multiple) thread 0: duration=10, iteration=6, product=60
-(alarm-multiple) thread 0: duration=10, iteration=7, product=70
-(alarm-multiple) thread 1: duration=20, iteration=4, product=80
-(alarm-multiple) thread 3: duration=40, iteration=2, product=80
-(alarm-multiple) thread 2: duration=30, iteration=3, product=90
-(alarm-multiple) thread 4: duration=50, iteration=2, product=100
-(alarm-multiple) thread 1: duration=20, iteration=5, product=100
-(alarm-multiple) thread 2: duration=30, iteration=4, product=120
-(alarm-multiple) thread 3: duration=40, iteration=3, product=120
-(alarm-multiple) thread 1: duration=20, iteration=6, product=120
-(alarm-multiple) thread 1: duration=20, iteration=7, product=140
-(alarm-multiple) thread 4: duration=50, iteration=3, product=150
-(alarm-multiple) thread 2: duration=30, iteration=5, product=150
-(alarm-multiple) thread 3: duration=40, iteration=4, product=160
-(alarm-multiple) thread 2: duration=30, iteration=6, product=180
-(alarm-multiple) thread 3: duration=40, iteration=5, product=200
-(alarm-multiple) thread 4: duration=50, iteration=4, product=200
-(alarm-multiple) thread 2: duration=30, iteration=7, product=210
-(alarm-multiple) thread 3: duration=40, iteration=6, product=240
-(alarm-multiple) thread 4: duration=50, iteration=5, product=250
-(alarm-multiple) thread 3: duration=40, iteration=7, product=280
-(alarm-multiple) thread 4: duration=50, iteration=6, product=300
-(alarm-multiple) thread 4: duration=50, iteration=7, product=350
-(alarm-multiple) end
-Execution of 'alarm-multiple' complete.
-Kernel PANIC at ../../threads/init.c:330 in run_actions(): unknown action `-x' (use -h for help)
-Call stack: 0xc00283de.
-The `backtrace' program can make call stacks useful.
-Read "Backtraces" in the "Debugging Tools" chapter
-of the Pintos documentation for more information.
View
7 src/threads/make.sh
@@ -1,7 +0,0 @@
-cd ../..
-git pull origin p
-cd src/threads
-make clean
-make
-cd build
-pintos -v -- run alarm-negative
View
646 src/threads/thread.c~
@@ -1,646 +0,0 @@
-#include "threads/thread.h"
-#include <debug.h>
-#include <stddef.h>
-#include <random.h>
-#include <stdio.h>
-#include <string.h>
-#include "threads/flags.h"
-#include "threads/interrupt.h"
-#include "threads/intr-stubs.h"
-#include "threads/palloc.h"
-#include "threads/switch.h"
-#include "threads/synch.h"
-#include "threads/vaddr.h"
-#ifdef USERPROG
-#include "userprog/process.h"
-#endif
-
-/* Random value for struct thread's `magic' member.
- Used to detect stack overflow. See the big comment at the top
- of thread.h for details. */
-#define THREAD_MAGIC 0xcd6abf4b
-
-/* List of processes in THREAD_READY state, that is, processes
- that are ready to run but not actually running. */
-static struct list ready_list;
-
-/* List of all processes. Processes are added to this list
- when they are first scheduled and removed when they exit. */
-static struct list all_list;
-
-/* Idle thread. */
-static struct thread *idle_thread;
-
-/* Initial thread, the thread running init.c:main(). */
-static struct thread *initial_thread;
-
-/* Lock used by allocate_tid(). */
-static struct lock tid_lock;
-
-/* Stack frame for kernel_thread(). */
-struct kernel_thread_frame
- {
- void *eip; /* Return address. */
- thread_func *function; /* Function to call. */
- void *aux; /* Auxiliary data for function. */
- };
-
-/* Statistics. */
-static long long idle_ticks; /* # of timer ticks spent idle. */
-static long long kernel_ticks; /* # of timer ticks in kernel threads. */
-static long long user_ticks; /* # of timer ticks in user programs. */
-
-/* Scheduling. */
-#define TIME_SLICE 4 /* # of timer ticks to give each thread. */
-static unsigned thread_ticks; /* # of timer ticks since last yield. */
-
-/* If false (default), use round-robin scheduler.
- If true, use multi-level feedback queue scheduler.
- Controlled by kernel command-line option "-o mlfqs". */
-bool thread_mlfqs;
-
-static void kernel_thread (thread_func *, void *aux);
-
-static void idle (void *aux UNUSED);
-static struct thread *running_thread (void);
-static struct thread *next_thread_to_run (void);
-static void init_thread (struct thread *, const char *name, int priority);
-static bool is_thread (struct thread *) UNUSED;
-static void *alloc_frame (struct thread *, size_t size);
-static void schedule (void);
-void thread_schedule_tail (struct thread *prev);
-static tid_t allocate_tid (void);
-
-/* Initializes the threading system by transforming the code
- that's currently running into a thread. This can't work in
- general and it is possible in this case only because loader.S
- was careful to put the bottom of the stack at a page boundary.
-
- Also initializes the run queue and the tid lock.
-
- After calling this function, be sure to initialize the page
- allocator before trying to create any threads with
- thread_create().
-
- It is not safe to call thread_current() until this function
- finishes. */
-void
-thread_init (void)
-{
- ASSERT (intr_get_level () == INTR_OFF);
-
- lock_init (&tid_lock);
- list_init (&ready_list);
- list_init (&all_list);
-
- /* Set up a thread structure for the running thread. */
- initial_thread = running_thread ();
- init_thread (initial_thread, "main", PRI_DEFAULT);
- initial_thread->status = THREAD_RUNNING;
- initial_thread->tid = allocate_tid ();
-
-
-}
-
-/* Starts preemptive thread scheduling by enabling interrupts.
- Also creates the idle thread. */
-void
-thread_start (void)
-{
- /* Create the idle thread. */
- struct semaphore idle_started;
- sema_init (&idle_started, 0);
- thread_create ("idle", PRI_MIN, idle, &idle_started);
-
- /* Start preemptive thread scheduling. */
- intr_enable ();
-
- /* Wait for the idle thread to initialize idle_thread. */
- sema_down (&idle_started);
-}
-
-/* Called by the timer interrupt handler at each timer tick.
- Thus, this function runs in an external interrupt context. */
-void
-thread_tick (void)
-{
- struct thread *t = thread_current ();
-
- /* Update statistics. */
- if (t == idle_thread)
- idle_ticks++;
-#ifdef USERPROG
- else if (t->pagedir != NULL)
- user_ticks++;
-#endif
- else
- kernel_ticks++;
-
- /* Enforce preemption. */
- if (++thread_ticks >= TIME_SLICE)
- intr_yield_on_return ();
-}
-
-/* Prints thread statistics. */
-void
-thread_print_stats (void)
-{
- printf ("Thread: %lld idle ticks, %lld kernel ticks, %lld user ticks\n",
- idle_ticks, kernel_ticks, user_ticks);
-}
-
-/* Creates a new kernel thread named NAME with the given initial
- PRIORITY, which executes FUNCTION passing AUX as the argument,
- and adds it to the ready queue. Returns the thread identifier
- for the new thread, or TID_ERROR if creation fails.
-
- If thread_start() has been called, then the new thread may be
- scheduled before thread_create() returns. It could even exit
- before thread_create() returns. Contrariwise, the original
- thread may run for any amount of time before the new thread is
- scheduled. Use a semaphore or some other form of
- synchronization if you need to ensure ordering.
-
- The code provided sets the new thread's `priority' member to
- PRIORITY, but no actual priority scheduling is implemented.
- Priority scheduling is the goal of Problem 1-3. */
-tid_t
-thread_create (const char *name, int priority,
- thread_func *function, void *aux)
-{
- struct thread *t;
- struct kernel_thread_frame *kf;
- struct switch_entry_frame *ef;
- struct switch_threads_frame *sf;
- tid_t tid;
- enum intr_level old_level;
-
- ASSERT (function != NULL);
-
- /* Allocate thread. */
- t = palloc_get_page (PAL_ZERO);
- if (t == NULL)
- return TID_ERROR;
-
- /* Initialize thread. */
- init_thread (t, name, priority);
- tid = t->tid = allocate_tid ();
-
- /* Prepare thread for first run by initializing its stack.
- Do this atomically so intermediate values for the 'stack'
- member cannot be observed. */
- old_level = intr_disable ();
-
- /* Stack frame for kernel_thread(). */
- kf = alloc_frame (t, sizeof *kf);
- kf->eip = NULL;
- kf->function = function;
- kf->aux = aux;
-
- /* Stack frame for switch_entry(). */
- ef = alloc_frame (t, sizeof *ef);
- ef->eip = (void (*) (void)) kernel_thread;
-
- /* Stack frame for switch_threads(). */
- sf = alloc_frame (t, sizeof *sf);
- sf->eip = switch_entry;
- sf->ebp = 0;
-
- intr_set_level (old_level);
-
- /* Add to run queue. */
- //printf("unblocking (%d)%s\n",(t->priority),(t->name));
- thread_unblock (t);
- //printf("done unblocking (%d)%s\n",(t->priority),(t->name));
-
- return tid;
-}
-
-/* Puts the current thread to sleep. It will not be scheduled
- again until awoken by thread_unblock().
-
- This function must be called with interrupts turned off. It
- is usually a better idea to use one of the synchronization
- primitives in synch.h. */
-void
-thread_block (void)
-{
- ASSERT (!intr_context ());
- ASSERT (intr_get_level () == INTR_OFF);
-
- thread_current ()->status = THREAD_BLOCKED;
- schedule ();
-}
-
-/* Transitions a blocked thread T to the ready-to-run state.
- This is an error if T is not blocked. (Use thread_yield() to
- make the running thread ready.)
-
- This function does not preempt the running thread. This can
- be important: if the caller had disabled interrupts itself,
- it may expect that it can atomically unblock a thread and
- update other data. */
-void
-thread_unblock (struct thread *t)
-{
- enum intr_level old_level;
-
- ASSERT (is_thread (t));
-
- old_level = intr_disable ();
- ASSERT (t->status == THREAD_BLOCKED);
- list_push_back (&ready_list, &t->elem);
- t->status = THREAD_READY;
-
- intr_set_level (old_level);
- if ((thread_current () != idle_thread) && (thread_current ()->priority) < (t->priority))
- {
- thread_yield();
- }
-}
-
-/* Returns the name of the running thread. */
-const char *
-thread_name (void)
-{
- return thread_current ()->name;
-}
-
-/* Returns the running thread.
- This is running_thread() plus a couple of sanity checks.
- See the big comment at the top of thread.h for details. */
-struct thread *
-thread_current (void)
-{
- struct thread *t = running_thread ();
-
- /* Make sure T is really a thread.
- If either of these assertions fire, then your thread may
- have overflowed its stack. Each thread has less than 4 kB
- of stack, so a few big automatic arrays or moderate
- recursion can cause stack overflow. */
- ASSERT (is_thread (t));
- ASSERT (t->status == THREAD_RUNNING);
-
- return t;
-}
-
-/* Returns the running thread's tid. */
-tid_t
-thread_tid (void)
-{
- return thread_current ()->tid;
-}
-
-/* Deschedules the current thread and destroys it. Never
- returns to the caller. */
-void
-thread_exit (void)
-{
- ASSERT (!intr_context ());
-
-#ifdef USERPROG
- process_exit ();
-#endif
-
- /* Remove thread from all threads list, set our status to dying,
- and schedule another process. That process will destroy us
- when it calls thread_schedule_tail(). */
- intr_disable ();
- list_remove (&thread_current()->allelem);
- thread_current ()->status = THREAD_DYING;
- schedule ();
- NOT_REACHED ();
-}
-
-/* Yields the CPU. The current thread is not put to sleep and
- may be scheduled again immediately at the scheduler's whim. */
-void
-thread_yield (void)
-{
- struct thread *cur = thread_current ();
- enum intr_level old_level;
-
- ASSERT (!intr_context ());
-
- old_level = intr_disable ();
- if (cur != idle_thread)
- list_push_back (&ready_list, &cur->elem);
- cur->status = THREAD_READY;
- schedule ();
- intr_set_level (old_level);
-}
-
-
-void thread_check_yield ()
-{
- struct list_elem* e;
- struct thread* e2;
- bool y = false;
- for (e = (list_begin (&ready_list)); e!= list_end (&ready_list);
- e = list_next(e))
- {
- e2 = list_entry (e, struct thread, elem);
- if ((e2->priority) >(thread_current ()->priority)){
- y = true;
- break;
- }
- }
- if (y){thread_yield();}
-}
-
-/* Invoke function 'func' on all threads, passing along 'aux'.
- This function must be called with interrupts off. */
-void
-thread_foreach (thread_action_func *func, void *aux)
-{
- struct list_elem *e;
-
- ASSERT (intr_get_level () == INTR_OFF);
-
- for (e = list_begin (&all_list); e != list_end (&all_list);
- e = list_next (e))
- {
- struct thread *t = list_entry (e, struct thread, allelem);
- func (t, aux);
- }
-}
-
-/* Sets the current thread's priority to NEW_PRIORITY. */
-void
-thread_set_priority (int new_priority)
-{
- thread_current ()->original_priority = new_priority;
- thread_get_priority();
- thread_check_yield ();
-}
-
-/* Returns the current thread's priority. */
-int
-thread_get_priority (void)
-{
- struct list_elem *e = list_begin (&(thread_current ()->benefactors))
- struct thread * t;
- for (e = ; e != list_end (&);
- e = list_next (e))
- while(e != list_end(&(thread_current ()->benefactors)))
- {
- struct thread *t = list_entry (e, struct thread, allelem);
- func (t, aux);
- }
- return thread_current ()->priority;
-}
-
-/* Sets the current thread's nice value to NICE. */
-void
-thread_set_nice (int nice UNUSED)
-{
- /* Not yet implemented. */
-}
-
-/* Returns the current thread's nice value. */
-int
-thread_get_nice (void)
-{
- /* Not yet implemented. */
- return 0;
-}
-
-/* Returns 100 times the system load average. */
-int
-thread_get_load_avg (void)
-{
- /* Not yet implemented. */
- return 0;
-}
-
-/* Returns 100 times the current thread's recent_cpu value. */
-int
-thread_get_recent_cpu (void)
-{
- /* Not yet implemented. */
- return 0;
-}
-
-/* Idle thread. Executes when no other thread is ready to run.
-
- The idle thread is initially put on the ready list by
- thread_start(). It will be scheduled once initially, at which
- point it initializes idle_thread, "up"s the semaphore passed
- to it to enable thread_start() to continue, and immediately
- blocks. After that, the idle thread never appears in the
- ready list. It is returned by next_thread_to_run() as a
- special case when the ready list is empty. */
-static void
-idle (void *idle_started_ UNUSED)
-{
- /*if (!list_empty (&ready_list)){printf("actual idle.......\n");}
- else{printf("fake idle.....\n");}*/
- struct semaphore *idle_started = idle_started_;
- idle_thread = thread_current ();
- sema_up (idle_started);
-
- for (;;)
- {
- /* Let someone else run. */
- intr_disable ();
- thread_block ();
-
- /* Re-enable interrupts and wait for the next one.
-
- The `sti' instruction disables interrupts until the
- completion of the next instruction, so these two
- instructions are executed atomically. This atomicity is
- important; otherwise, an interrupt could be handled
- between re-enabling interrupts and waiting for the next
- one to occur, wasting as much as one clock tick worth of
- time.
-
- See [IA32-v2a] "HLT", [IA32-v2b] "STI", and [IA32-v3a]
- 7.11.1 "HLT Instruction". */
- asm volatile ("sti; hlt" : : : "memory");
- }
-}
-
-/* Function used as the basis for a kernel thread. */
-static void
-kernel_thread (thread_func *function, void *aux)
-{
- ASSERT (function != NULL);
-
- intr_enable (); /* The scheduler runs with interrupts off. */
- function (aux); /* Execute the thread function. */
- thread_exit (); /* If function() returns, kill the thread. */
-}
-
-/* Returns the running thread. */
-struct thread *
-running_thread (void)
-{
- uint32_t *esp;
-
- /* Copy the CPU's stack pointer into `esp', and then round that
- down to the start of a page. Because `struct thread' is
- always at the beginning of a page and the stack pointer is
- somewhere in the middle, this locates the curent thread. */
- asm ("mov %%esp, %0" : "=g" (esp));
- return pg_round_down (esp);
-}
-
-/* Returns true if T appears to point to a valid thread. */
-static bool
-is_thread (struct thread *t)
-{
- return t != NULL && t->magic == THREAD_MAGIC;
-}
-
-/* Does basic initialization of T as a blocked thread named
- NAME. */
-static void
-init_thread (struct thread *t, const char *name, int priority)
-{
- ASSERT (t != NULL);
- ASSERT (PRI_MIN <= priority && priority <= PRI_MAX);
- ASSERT (name != NULL);
-
- memset (t, 0, sizeof *t);
- t->status = THREAD_BLOCKED;
- strlcpy (t->name, name, sizeof t->name);
- t->stack = (uint8_t *) t + PGSIZE;
- t->priority = priority;
- t->original_priority = priority;
- t->magic = THREAD_MAGIC;
- list_init(&t->benefactors);
- list_push_back (&all_list, &t->allelem);
- sema_init(&t->sema_wakeup, 0);
-}
-
-/* Allocates a SIZE-byte frame at the top of thread T's stack and
- returns a pointer to the frame's base. */
-static void *
-alloc_frame (struct thread *t, size_t size)
-{
- /* Stack data is always allocated in word-size units. */
- ASSERT (is_thread (t));
- ASSERT (size % sizeof (uint32_t) == 0);
-
- t->stack -= size;
- return t->stack;
-}
-
-/* Chooses and returns the next thread to be scheduled. Should
- return a thread from the run queue, unless the run queue is
- empty. (If the running thread can continue running, then it
- will be in the run queue.) If the run queue is empty, return
- idle_thread. */
-static struct thread *
-next_thread_to_run (void)
-{
- if (list_empty (&ready_list)){return idle_thread;}
- else{
- struct list_elem* e;
- struct list_elem* t = NULL;
- struct thread* e2;
- struct thread* t2 = NULL;
- for (e = (list_begin (&ready_list)); e!= list_end (&ready_list);
- e = list_next(e))
- {
- e2 = list_entry (e, struct thread, elem);
- if (t2==NULL||(e2->priority)>(t2->priority)){
- t = e;
- t2 = e2;
- }
- }
- if( t!= NULL){list_remove(t);return t2;}
- printf("uh oh......\n");
- return idle_thread;
- //return list_entry (list_pop_front (&ready_list), struct thread, elem);
- }
-}
-
-/* Completes a thread switch by activating the new thread's page
- tables, and, if the previous thread is dying, destroying it.
-
- At this function's invocation, we just switched from thread
- PREV, the new thread is already running, and interrupts are
- still disabled. This function is normally invoked by
- thread_schedule() as its final action before returning, but
- the first time a thread is scheduled it is called by
- switch_entry() (see switch.S).
-
- It's not safe to call printf() until the thread switch is
- complete. In practice that means that printf()s should be
- added at the end of the function.
-
- After this function and its caller returns, the thread switch
- is complete. */
-void
-thread_schedule_tail (struct thread *prev)
-{
- struct thread *cur = running_thread ();
-
- ASSERT (intr_get_level () == INTR_OFF);
-
- /* Mark us as running. */
- cur->status = THREAD_RUNNING;
-
- /* Start new time slice. */
- thread_ticks = 0;
-
-#ifdef USERPROG
- /* Activate the new address space. */
- process_activate ();
-#endif
-
- /* If the thread we switched from is dying, destroy its struct
- thread. This must happen late so that thread_exit() doesn't
- pull out the rug under itself. (We don't free
- initial_thread because its memory was not obtained via
- palloc().) */
- if (prev != NULL && prev->status == THREAD_DYING && prev != initial_thread)
- {
- ASSERT (prev != cur);
- palloc_free_page (prev);
- }
-}
-
-/* Schedules a new process. At entry, interrupts must be off and
- the running process's state must have been changed from
- running to some other state. This function finds another
- thread to run and switches to it.
-
- It's not safe to call printf() until thread_schedule_tail()
- has completed. */
-static void
-schedule (void)
-{
- struct thread *cur = running_thread ();
- struct thread *next = next_thread_to_run ();
- struct thread *prev = NULL;
- ASSERT (intr_get_level () == INTR_OFF);
- ASSERT (cur->status != THREAD_RUNNING);
- ASSERT (is_thread (next));
-
- if (cur != next)
- prev = switch_threads (cur, next);
- thread_schedule_tail (prev);
-}
-
-/* Returns a tid to use for a new thread. */
-static tid_t
-allocate_tid (void)
-{
- static tid_t next_tid = 1;
- tid_t tid;
-
- lock_acquire (&tid_lock);
- tid = next_tid++;
- lock_release (&tid_lock);
-
- return tid;
-}
-
-
-/* Offset of `stack' member within `struct thread'.
- Used by switch.S, which can't figure it out on its own. */
-uint32_t thread_stack_ofs = offsetof (struct thread, stack);
View
150 src/threads/thread.h~
@@ -1,150 +0,0 @@
-#ifndef THREADS_THREAD_H
-#define THREADS_THREAD_H
-
-#include <debug.h>
-#include <list.h>
-#include <stdint.h>
-#include "synch.h"
-
-/* States in a thread's life cycle. */
-enum thread_status
- {
- THREAD_RUNNING, /* Running thread. */
- THREAD_READY, /* Not running but ready to run. */
- THREAD_BLOCKED, /* Waiting for an event to trigger. */
- THREAD_DYING /* About to be destroyed. */
- };
-
-/* Thread identifier type.
- You can redefine this to whatever type you like. */
-typedef int tid_t;
-#define TID_ERROR ((tid_t) -1) /* Error value for tid_t. */
-
-/* Thread priorities. */
-#define PRI_MIN 0 /* Lowest priority. */
-#define PRI_DEFAULT 31 /* Default priority. */
-#define PRI_MAX 63 /* Highest priority. */
-
-/* A kernel thread or user process.
-
- Each thread structure is stored in its own 4 kB page. The
- thread structure itself sits at the very bottom of the page
- (at offset 0). The rest of the page is reserved for the
- thread's kernel stack, which grows downward from the top of
- the page (at offset 4 kB). Here's an illustration:
-
- 4 kB +---------------------------------+
- | kernel stack |
- | | |
- | | |
- | V |
- | grows downward |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- +---------------------------------+
- | magic |
- | : |
- | : |
- | name |
- | status |
- 0 kB +---------------------------------+
-
- The upshot of this is twofold:
-
- 1. First, `struct thread' must not be allowed to grow too
- big. If it does, then there will not be enough room for
- the kernel stack. Our base `struct thread' is only a
- few bytes in size. It probably should stay well under 1
- kB.
-
- 2. Second, kernel stacks must not be allowed to grow too
- large. If a stack overflows, it will corrupt the thread
- state. Thus, kernel functions should not allocate large
- structures or arrays as non-static local variables. Use
- dynamic allocation with malloc() or palloc_get_page()
- instead.
-
- The first symptom of either of these problems will probably be
- an assertion failure in thread_current(), which checks that
- the `magic' member of the running thread's `struct thread' is
- set to THREAD_MAGIC. Stack overflow will normally change this
- value, triggering the assertion. */
-/* The `elem' member has a dual purpose. It can be an element in
- the run queue (thread.c), or it can be an element in a
- semaphore wait list (synch.c). It can be used these two ways
- only because they are mutually exclusive: only a thread in the
- ready state is on the run queue, whereas only a thread in the
- blocked state is on a semaphore wait list. */
-struct thread
- {
- /* Owned by thread.c. */
- tid_t tid; /* Thread identifier. */
- enum thread_status status; /* Thread state. */
- char name[16]; /* Name (for debugging purposes). */
- uint8_t *stack; /* Saved stack pointer. */
- int priority; /* Priority. */
- int original_priority; /* Base level thread priority */
- struct list_elem allelem; /* List element for all threads list. */
- int64_t wakeup_time;
- struct semaphore sema_wakeup;
- /* Shared between thread.c and synch.c. */
- struct list_elem elem; /* List element. */
- struct list_elem timer_list_elem;
- struct list benefactors;
- struct thread* donee;
- struct lock* want_lock;
-#ifdef USERPROG
- /* Owned by userprog/process.c. */
- uint32_t *pagedir; /* Page directory. */
-#endif
-
- /* Owned by thread.c. */
- unsigned magic; /* Detects stack overflow. */
- };
-
-/* If false (default), use round-robin scheduler.
- If true, use multi-level feedback queue scheduler.
- Controlled by kernel command-line option "-o mlfqs". */
-extern bool thread_mlfqs;
-
-void thread_init (void);
-void thread_start (void);
-
-void thread_tick (void);
-void thread_print_stats (void);
-
-typedef void thread_func (void *aux);
-tid_t thread_create (const char *name, int priority, thread_func *, void *);
-
-void thread_block (void);
-void thread_unblock (struct thread *);
-void thread_release_lock (struct lock*);
-
-struct thread *thread_current (void);
-tid_t thread_tid (void);
-const char *thread_name (void);
-
-void thread_exit (void) NO_RETURN;
-void thread_yield (void);
-void thread_check_yield (void);
-
-/* Performs some operation on thread t, given auxiliary data AUX. */
-typedef void thread_action_func (struct thread *t, void *aux);
-void thread_foreach (thread_action_func *, void *);
-
-int thread_get_priority (void);
-void thread_set_priority (int);
-void thread_re
-
-int thread_get_nice (void);
-void thread_set_nice (int);
-int thread_get_recent_cpu (void);
-int thread_get_load_avg (void);
-
-#endif /* threads/thread.h */
View
20 src/utils/pintos-gdb~
@@ -1,20 +0,0 @@
-#! /bin/sh
-
-# Path to GDB macros file. Customize for your site.
-GDBMACROS=/usr/local/bin/gdb-macros
-
-# Choose correct GDB.
-if command -v i386-elf-gdb >/dev/null 2>&1; then
- GDB=i386-elf-gdb
-else
- GDB=gdb
-fi
-
-# Run GDB.
-if test -f "$GDBMACROS"; then
- exec $GDB -x "$GDBMACROS" "$@"
-else
- echo "*** $GDBMACROS does not exist ***"
- echo "*** Pintos GDB macros will not be available ***"
- exec $GDB "$@"
-fi
Please sign in to comment.
Something went wrong with that request. Please try again.