listpop implemented
This commit is contained in:
parent
a962ad2132
commit
7bb6e7cbc0
8 changed files with 73 additions and 185 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -58,5 +58,5 @@ dkms.conf
|
|||
|
||||
/.vagrant/**/*
|
||||
|
||||
**/bochsout.txt
|
||||
**/bochsrc.txt
|
||||
/**/bochsout.txt
|
||||
/**/bochsrc.txt
|
||||
|
|
|
@ -37,6 +37,7 @@ tests/threads_SRC += tests/threads/mlfqs-recent-1.c
|
|||
tests/threads_SRC += tests/threads/mlfqs-fair.c
|
||||
tests/threads_SRC += tests/threads/mlfqs-block.c
|
||||
tests/threads_SRC += tests/threads/hello.c
|
||||
tests/threads_SRC += tests/threads/listpop.c
|
||||
|
||||
MLFQS_OUTPUTS = \
|
||||
tests/threads/mlfqs-load-1.output \
|
||||
|
|
56
pintos-env/pintos/tests/threads/listpop.c
Normal file
56
pintos-env/pintos/tests/threads/listpop.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "listpop.h"
|
||||
#include <stdio.h>
|
||||
#include "../lib/kernel/list.h"
|
||||
#include "../threads/malloc.h"
|
||||
|
||||
static void populate(struct list* l, int* a, int n);
|
||||
static bool compare_items(const struct list_elem * a, const struct list_elem * b, void * aux);
|
||||
static void print_sorted(struct list* l);
|
||||
static void free_populated(struct list* l);
|
||||
|
||||
struct item {
|
||||
struct list_elem elem;
|
||||
int priority;
|
||||
};
|
||||
|
||||
void populate(struct list* l, int* a, int n) {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
struct item* it = malloc(sizeof(struct item));
|
||||
it->priority = a[i];
|
||||
list_push_back(l, &(it->elem));
|
||||
}
|
||||
}
|
||||
|
||||
bool compare_items(const struct list_elem * a, const struct list_elem * b, void * aux) {
|
||||
struct item * ia = list_entry(a, struct item, elem);
|
||||
struct item * ib = list_entry(b, struct item, elem);
|
||||
return (ia->priority < ib->priority);
|
||||
}
|
||||
|
||||
void print_sorted(struct list* l) {
|
||||
list_sort(l, compare_items, NULL);
|
||||
struct list_elem* e;
|
||||
for (e = list_begin(l); e != list_end(l); e = list_next(e)) {
|
||||
struct item* i = list_entry(e, struct item, elem);
|
||||
printf("%d\n", i->priority);
|
||||
}
|
||||
}
|
||||
|
||||
void free_populated(struct list* l) {
|
||||
struct list_elem* e;
|
||||
for (e = list_begin(l); e != list_end(l);) {
|
||||
struct item* i = list_entry(e, struct item, elem);
|
||||
e = list_next(e);
|
||||
free(i);
|
||||
}
|
||||
}
|
||||
|
||||
void test_list(void) {
|
||||
struct list l;
|
||||
list_init(&l);
|
||||
|
||||
populate(&l, ITEMARRAY, ITEMCOUNT);
|
||||
print_sorted(&l);
|
||||
free_populated(&l);
|
||||
}
|
4
pintos-env/pintos/tests/threads/listpop.h
Normal file
4
pintos-env/pintos/tests/threads/listpop.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#define ITEMCOUNT 10
|
||||
int ITEMARRAY[ITEMCOUNT] = {3,1,4,2,7,6,9,5,8,3};
|
||||
|
||||
extern void test_list(void);
|
|
@ -39,6 +39,7 @@ static const struct test tests[] =
|
|||
{"mlfqs-nice-10", test_mlfqs_nice_10},
|
||||
{"mlfqs-block", test_mlfqs_block},
|
||||
{"test_hello", test_hello},
|
||||
{"test_list", test_list},
|
||||
};
|
||||
|
||||
static const char *test_name;
|
||||
|
|
|
@ -33,6 +33,7 @@ extern test_func test_mlfqs_nice_2;
|
|||
extern test_func test_mlfqs_nice_10;
|
||||
extern test_func test_mlfqs_block;
|
||||
extern test_func test_hello;
|
||||
extern test_func test_list;
|
||||
|
||||
void msg (const char *, ...);
|
||||
void fail (const char *, ...);
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
00000000000i[ ] Bochs x86 Emulator 2.6
|
||||
00000000000i[ ] Built from SVN snapshot on September 2nd, 2012
|
||||
00000000000i[ ] Compiled on Feb 17 2015 at 16:28:11
|
||||
00000000000i[ ] System configuration
|
||||
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
|
||||
00000000000i[ ] A20 line support: yes
|
||||
00000000000i[ ] IPS is set to 1000000
|
||||
00000000000i[ ] CPU configuration
|
||||
00000000000i[ ] level: 6
|
||||
00000000000i[ ] SMP support: no
|
||||
00000000000i[ ] APIC support: xapic
|
||||
00000000000i[ ] FPU support: yes
|
||||
00000000000i[ ] MMX support: yes
|
||||
00000000000i[ ] 3dnow! support: no
|
||||
00000000000i[ ] SEP support: yes
|
||||
00000000000i[ ] SSE support: sse2
|
||||
00000000000i[ ] XSAVE support: no
|
||||
00000000000i[ ] AES support: no
|
||||
00000000000i[ ] MOVBE support: no
|
||||
00000000000i[ ] ADX support: no
|
||||
00000000000i[ ] x86-64 support: no
|
||||
00000000000i[ ] MWAIT support: yes
|
||||
00000000000i[ ] Optimization configuration
|
||||
00000000000i[ ] RepeatSpeedups support: no
|
||||
00000000000i[ ] Fast function calls: no
|
||||
00000000000i[ ] Handlers Chaining speedups: no
|
||||
00000000000i[ ] Devices configuration
|
||||
00000000000i[ ] NE2000 support: no
|
||||
00000000000i[ ] PCI support: no, enabled=no
|
||||
00000000000i[ ] SB16 support: no
|
||||
00000000000i[ ] USB support: no
|
||||
00000000000i[ ] VGA extension support: vbe
|
||||
00000000000i[MEM0 ] allocated memory at 0x7eff051e8010. after alignment, vector=0x7eff051e9000
|
||||
00000000000i[MEM0 ] 4.00MB
|
||||
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=4
|
||||
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/pintos-env/share/bochs/BIOS-bochs-latest')
|
||||
00000000000i[ ] init_dev of 'cmos' plugin device by virtual method
|
||||
00000000000i[CMOS ] Using specified time for initial clock
|
||||
00000000000i[CMOS ] Setting initial clock to: Thu Jan 1 00:00:00 1970 (time0=0)
|
||||
00000000000i[ ] init_dev of 'dma' plugin device by virtual method
|
||||
00000000000i[DMA ] channel 4 used by cascade
|
||||
00000000000i[ ] init_dev of 'pic' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'pit' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'floppy' plugin device by virtual method
|
||||
00000000000i[DMA ] channel 2 used by Floppy Drive
|
||||
00000000000i[ ] init_dev of 'vga' plugin device by virtual method
|
||||
00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x00000000000bffff
|
||||
00000000000i[VGA ] interval=200000
|
||||
00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x00000000e0ffffff
|
||||
00000000000i[BXVGA] VBE Bochs Display Extension Enabled
|
||||
00000000000i[MEM0 ] rom at 0xc0000/41472 ('/pintos-env/share/bochs/VGABIOS-lgpl-latest')
|
||||
00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
|
||||
00000000000i[IOAP ] initializing I/O APIC
|
||||
00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x00000000fec00fff
|
||||
00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
|
||||
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
|
||||
00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
|
||||
00000000000i[HD ] HD on ata0-0: '/tmp/lA8HTUhyge.dsk', 'flat' mode
|
||||
00000000000i[IMG ] hd_size: 516096
|
||||
00000000000i[HD ] ata0-0: using specified geometry: CHS=1/16/63
|
||||
00000000000i[HD ] Using boot sequence disk, none, none
|
||||
00000000000i[HD ] Floppy boot signature check is enabled
|
||||
00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
|
||||
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
|
||||
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
|
||||
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
|
||||
00000000000i[SER ] com1 at 0x03f8 irq 4
|
||||
00000000000i[ ] register state of 'cmos' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'dma' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'pic' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'pit' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'floppy' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'vga' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'unmapped' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'biosdev' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'speaker' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'parallel' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'serial' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'ioapic' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'keyboard' plugin device by virtual method
|
||||
00000000000i[ ] register state of 'harddrv' plugin device by virtual method
|
||||
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
|
||||
00000000000i[CPU0 ] cpu hardware reset
|
||||
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
|
||||
00000000000i[CPU0 ] CPUID[0x00000000]: 00000002 756e6547 6c65746e 49656e69
|
||||
00000000000i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00000008 1fcbfbff
|
||||
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
|
||||
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
|
||||
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000000 00000000
|
||||
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
|
||||
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
|
||||
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
|
||||
00000000000i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
|
||||
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
|
||||
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
|
||||
00000000000i[CPU0 ] CPUID[0x80000008]: 00002028 00000000 00000000 00000000
|
||||
00000000000i[ ] reset of 'cmos' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'dma' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'pic' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'pit' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'floppy' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'vga' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'ioapic' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'unmapped' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'biosdev' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'speaker' plugin device by virtual method
|
||||
00000000000e[SPEAK] Failed to open /dev/console: Permission denied
|
||||
00000000000e[SPEAK] Deactivating beep on console
|
||||
00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'parallel' plugin device by virtual method
|
||||
00000000000i[ ] reset of 'serial' plugin device by virtual method
|
||||
00000000025i[MEM0 ] allocate_block: block=0x0 used 0x1 of 0x4
|
||||
00000004661i[BIOS ] $Revision: 11318 $ $Date: 2012-08-06 19:59:54 +0200 (Mo, 06. Aug 2012) $
|
||||
00000317820i[KBD ] reset-disable command received
|
||||
00000319072i[BIOS ] Starting rombios32
|
||||
00000319506i[BIOS ] Shutdown flag 0
|
||||
00000320089i[BIOS ] ram_size=0x00400000
|
||||
00000320487i[BIOS ] ram_end=4MB
|
||||
00000331328i[BIOS ] Found 1 cpu(s)
|
||||
00000345510i[BIOS ] bios_table_addr: 0x000fa438 end=0x000fcc00
|
||||
00000363970i[BIOS ] bios_table_cur_addr: 0x000fa438
|
||||
00000491587i[VBIOS] VGABios $Id: vgabios.c,v 1.75 2011/10/15 14:07:21 vruppert Exp $
|
||||
00000491658i[BXVGA] VBE known Display Interface b0c0
|
||||
00000491690i[BXVGA] VBE known Display Interface b0c5
|
||||
00000494615i[VBIOS] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp $
|
||||
00000833946i[BIOS ] ata0-0: PCHS=1/16/63 translation=none LCHS=1/16/63
|
||||
00004712316i[BIOS ] IDE time out
|
||||
00007773617i[BIOS ] Booting from 0000:7c00
|
||||
00008171407i[MEM0 ] allocate_block: block=0x1 used 0x2 of 0x4
|
||||
00008212308i[MEM0 ] allocate_block: block=0x2 used 0x3 of 0x4
|
||||
01030203991i[NGUI ] ips = 1030.204M
|
||||
02144669032i[NGUI ] ips = 1114.465M
|
||||
03262317300i[NGUI ] ips = 1117.648M
|
||||
04381040700i[NGUI ] ips = 1118.723M
|
||||
04982866726p[ ] >>PANIC<< SIGNAL 2 caught
|
||||
04982866726i[CPU0 ] CPU is in protected mode (halted)
|
||||
04982866726i[CPU0 ] CS.mode = 32 bit
|
||||
04982866726i[CPU0 ] SS.mode = 32 bit
|
||||
04982866726i[CPU0 ] EFER = 0x00000000
|
||||
04982866726i[CPU0 ] | EAX=00000000 EBX=c0020fd7 ECX=c0103000 EDX=00000018
|
||||
04982866726i[CPU0 ] | ESP=c0103fa8 EBP=00000000 ESI=00000000 EDI=00000000
|
||||
04982866726i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf SF zf AF pf cf
|
||||
04982866726i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
|
||||
04982866726i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
|
||||
04982866726i[CPU0 ] | EIP=c0020ffc (c0020ffc)
|
||||
04982866726i[CPU0 ] | CR0=0xe0010015 CR2=0x00000000
|
||||
04982866726i[CPU0 ] | CR3=0x00101000 CR4=0x00000000
|
||||
04982866726i[CPU0 ] 0xc0020ffc>> lea esi, dword ptr ds:[esi] : 8D742600
|
||||
04982866726i[CMOS ] Last time is 4982 (Thu Jan 1 01:23:02 1970)
|
||||
04982866726i[NGUI ] bx_nogui_gui_c::exit() not implemented yet.
|
||||
04982866726i[ ] restoring default signal behavior
|
||||
04982866726i[CTRL ] quit_sim called with exit code 1
|
|
@ -1,12 +0,0 @@
|
|||
romimage: file=$BXSHARE/BIOS-bochs-latest
|
||||
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
|
||||
boot: disk
|
||||
cpu: ips=1000000
|
||||
megs: 4
|
||||
log: bochsout.txt
|
||||
panic: action=fatal
|
||||
user_shortcut: keys=ctrlaltdel
|
||||
clock: sync=none, time0=0
|
||||
ata0-master: type=disk, path=/tmp/lA8HTUhyge.dsk, mode=flat, cylinders=1, heads=16, spt=63, translation=none
|
||||
com1: enabled=1, mode=file, dev=/dev/stdout
|
||||
display_library: nogui
|
Reference in a new issue