From 7227acd1b6dba8e019be34297565a11abce78cfb Mon Sep 17 00:00:00 2001 From: Your Name <you@example.com> Date: Sun, 1 Jun 2025 17:35:48 +0000 Subject: [PATCH] lv2 --- Makefile | 10 +- kernel/include/initcode.h | 262 ++++++++++++++++++++------------------ kernel/include/proc.h | 7 + kernel/include/sysnum.h | 16 ++- kernel/include/time.h | 9 ++ kernel/include/types.h | 2 + kernel/proc.c | 85 +++++++++++++ kernel/syscall.c | 23 +++- kernel/sysproc.c | 135 +++++++++++++++++++- xv6-user/init.c | 11 ++ xv6-user/user.h | 10 +- xv6-user/usys.pl | 9 +- 12 files changed, 446 insertions(+), 133 deletions(-) create mode 100644 kernel/include/time.h diff --git a/Makefile b/Makefile index 39a125c..ed32999 100644 --- a/Makefile +++ b/Makefile @@ -232,8 +232,14 @@ fs: $(UPROGS) @cp README $(dst)/README @cp -r ./riscv64/* $(dst) @for file in $$( ls $U/_* ); do \ - cp $$file $(dst)/$${file#$U/_};\ - cp $$file $(dst)/bin/$${file#$U/_}; done + if [ $${file##*/} = "_sleep" ]; then \ + cp $$file $(dst)/$${file#$U/};\ + cp $$file $(dst)/bin/$${file#$U/};\ + else \ + cp $$file $(dst)/$${file#$U/_}; \ + cp $$file $(dst)/bin/$${file#$U/_}; \ + fi; \ + done @umount $(dst) # Write mounted sdcard diff --git a/kernel/include/initcode.h b/kernel/include/initcode.h index 76ea48a..ad7d656 100644 --- a/kernel/include/initcode.h +++ b/kernel/include/initcode.h @@ -1,20 +1,20 @@ 0x79,0x71,0x06,0xf4,0x22,0xf0,0x26,0xec,0x4a,0xe8,0x4e,0xe4,0x00,0x18,0x01,0x46, -0x85,0x45,0x09,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0x45,0x01,0x45,0x97,0x00, -0x00,0x00,0xe7,0x80,0xa0,0x41,0x01,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0x00,0x41, -0x17,0x15,0x00,0x00,0x13,0x05,0x05,0x91,0x97,0x00,0x00,0x00,0xe7,0x80,0x00,0x76, -0x97,0x17,0x00,0x00,0x83,0xa7,0x07,0xa2,0x63,0x5e,0xf0,0x0a,0x01,0x49,0x97,0x19, -0x00,0x00,0x93,0x89,0x29,0xa1,0x8d,0xa8,0x17,0x15,0x00,0x00,0x13,0x05,0x05,0x90, -0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0x73,0x05,0x45,0x97,0x00,0x00,0x00,0xe7,0x80, -0xa0,0x36,0x0e,0x09,0x97,0x14,0x00,0x00,0x93,0x84,0x44,0x9f,0xca,0x94,0x8c,0x60, -0x17,0x15,0x00,0x00,0x13,0x05,0x05,0x8f,0x97,0x00,0x00,0x00,0xe7,0x80,0x00,0x71, -0x97,0x15,0x00,0x00,0x93,0x85,0x05,0xa0,0x88,0x60,0x97,0x00,0x00,0x00,0xe7,0x80, -0x60,0x37,0x8c,0x60,0x17,0x15,0x00,0x00,0x13,0x05,0x45,0x8e,0x97,0x00,0x00,0x00, -0xe7,0x80,0xc0,0x6e,0x05,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0xe0,0x31,0x05,0x29, +0x85,0x45,0x09,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0x45,0x01,0x45,0x97,0x00, +0x00,0x00,0xe7,0x80,0x00,0x42,0x01,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0x41, +0x17,0x15,0x00,0x00,0x13,0x05,0x85,0x95,0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0x7a, +0x97,0x17,0x00,0x00,0x83,0xa7,0x87,0xac,0x63,0x5e,0xf0,0x0a,0x01,0x49,0x97,0x19, +0x00,0x00,0x93,0x89,0xa9,0xab,0x8d,0xa8,0x17,0x15,0x00,0x00,0x13,0x05,0x85,0x94, +0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0x78,0x05,0x45,0x97,0x00,0x00,0x00,0xe7,0x80, +0xa0,0x36,0x0e,0x09,0x97,0x14,0x00,0x00,0x93,0x84,0xc4,0xa9,0xca,0x94,0x8c,0x60, +0x17,0x15,0x00,0x00,0x13,0x05,0x85,0x93,0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0x75, +0x97,0x15,0x00,0x00,0x93,0x85,0x05,0xb0,0x88,0x60,0x97,0x00,0x00,0x00,0xe7,0x80, +0xc0,0x37,0x8c,0x60,0x17,0x15,0x00,0x00,0x13,0x05,0xc5,0x92,0x97,0x00,0x00,0x00, +0xe7,0x80,0x80,0x73,0x05,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0xe0,0x31,0x05,0x29, 0x83,0xa7,0x09,0x00,0x63,0x50,0xf9,0x04,0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0x30, 0xaa,0x84,0xe3,0x43,0x05,0xf8,0x51,0xdd,0x01,0x45,0x97,0x00,0x00,0x00,0xe7,0x80, 0x40,0x30,0xe3,0x8e,0xa4,0xfc,0xe3,0x59,0x05,0xfe,0x17,0x15,0x00,0x00,0x13,0x05, -0x65,0x8b,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0x6a,0x05,0x45,0x97,0x00,0x00,0x00, -0xe7,0x80,0x80,0x2d,0x97,0x00,0x00,0x00,0xe7,0x80,0x20,0x3b,0x01,0x45,0xa2,0x70, +0xe5,0x8f,0x97,0x00,0x00,0x00,0xe7,0x80,0x20,0x6f,0x05,0x45,0x97,0x00,0x00,0x00, +0xe7,0x80,0x80,0x2d,0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0x3b,0x01,0x45,0xa2,0x70, 0x02,0x74,0xe2,0x64,0x42,0x69,0xa2,0x69,0x45,0x61,0x82,0x80,0x41,0x11,0x22,0xe4, 0x00,0x08,0xaa,0x87,0x85,0x05,0x85,0x07,0x03,0xc7,0xf5,0xff,0xa3,0x8f,0xe7,0xfe, 0x75,0xfb,0x22,0x64,0x41,0x01,0x82,0x80,0x41,0x11,0x22,0xe4,0x00,0x08,0x83,0x47, @@ -33,14 +33,14 @@ 0xe5,0xbf,0x1d,0x71,0x86,0xec,0xa2,0xe8,0xa6,0xe4,0xca,0xe0,0x4e,0xfc,0x52,0xf8, 0x56,0xf4,0x5a,0xf0,0x5e,0xec,0x62,0xe8,0x80,0x10,0xaa,0x8b,0x2e,0x8a,0x2a,0x89, 0x81,0x44,0x93,0x0a,0xf4,0xfa,0x29,0x4b,0x35,0x4c,0xa6,0x89,0x85,0x24,0x63,0xd7, -0x44,0x03,0x05,0x46,0xd6,0x85,0x01,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0x1b, +0x44,0x03,0x05,0x46,0xd6,0x85,0x01,0x45,0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0x1b, 0x63,0x5e,0xa0,0x00,0x83,0x47,0xf4,0xfa,0x23,0x00,0xf9,0x00,0x63,0x87,0x67,0x01, 0x05,0x09,0xe3,0x9c,0x87,0xfd,0xa6,0x89,0x11,0xa0,0xa6,0x89,0xde,0x99,0x23,0x80, 0x09,0x00,0x5e,0x85,0xe6,0x60,0x46,0x64,0xa6,0x64,0x06,0x69,0xe2,0x79,0x42,0x7a, 0xa2,0x7a,0x02,0x7b,0xe2,0x6b,0x42,0x6c,0x25,0x61,0x82,0x80,0x01,0x11,0x06,0xec, 0x22,0xe8,0x26,0xe4,0x4a,0xe0,0x00,0x10,0x2e,0x89,0x81,0x45,0x97,0x00,0x00,0x00, -0xe7,0x80,0xc0,0x18,0x63,0x45,0x05,0x02,0xaa,0x84,0xca,0x85,0x97,0x00,0x00,0x00, -0xe7,0x80,0x40,0x18,0x2a,0x89,0x26,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0x15, +0xe7,0x80,0x20,0x19,0x63,0x45,0x05,0x02,0xaa,0x84,0xca,0x85,0x97,0x00,0x00,0x00, +0xe7,0x80,0xa0,0x18,0x2a,0x89,0x26,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0x15, 0x4a,0x85,0xe2,0x60,0x42,0x64,0xa2,0x64,0x02,0x69,0x05,0x61,0x82,0x80,0x7d,0x59, 0xc5,0xbf,0x41,0x11,0x22,0xe4,0x00,0x08,0x03,0x47,0x05,0x00,0x93,0x07,0xd0,0x02, 0x85,0x45,0x63,0x03,0xf7,0x04,0x03,0x47,0x05,0x00,0x9b,0x07,0x07,0xfd,0x93,0xf7, @@ -60,110 +60,126 @@ 0x01,0x45,0xe5,0xbf,0x41,0x11,0x06,0xe4,0x22,0xe0,0x00,0x08,0x97,0x00,0x00,0x00, 0xe7,0x80,0x60,0xf6,0xa2,0x60,0x02,0x64,0x41,0x01,0x82,0x80,0x85,0x48,0x73,0x00, 0x00,0x00,0x82,0x80,0x93,0x08,0xd0,0x05,0x73,0x00,0x00,0x00,0x82,0x80,0x8d,0x48, -0x73,0x00,0x00,0x00,0x82,0x80,0x91,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0x95,0x48, -0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x00,0x04,0x73,0x00,0x00,0x00,0x82,0x80, -0xd5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0x99,0x48,0x73,0x00,0x00,0x00,0x82,0x80, -0x9d,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xbd,0x48,0x73,0x00,0x00,0x00,0x82,0x80, -0xa1,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xd1,0x48,0x73,0x00,0x00,0x00,0x82,0x80, -0xa5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xa9,0x48,0x73,0x00,0x00,0x00,0x82,0x80, -0x93,0x08,0xc0,0x0a,0x73,0x00,0x00,0x00,0x82,0x80,0xb1,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0xb5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xb9,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0xd9,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xdd,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0xe1,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xc5,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0xe5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xc9,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0xcd,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xe9,0x48,0x73,0x00,0x00,0x00, -0x82,0x80,0x93,0x08,0x90,0x09,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x00,0x0a, -0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0xf0,0x0f,0x73,0x00,0x00,0x00,0x82,0x80, -0x01,0x11,0x06,0xec,0x22,0xe8,0x00,0x10,0xa3,0x07,0xb4,0xfe,0x05,0x46,0x93,0x05, -0xf4,0xfe,0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0xf2,0xe2,0x60,0x42,0x64,0x05,0x61, -0x82,0x80,0x39,0x71,0x06,0xfc,0x22,0xf8,0x26,0xf4,0x4a,0xf0,0x4e,0xec,0x80,0x00, -0xaa,0x84,0x99,0xc2,0x63,0xc8,0x05,0x08,0x81,0x25,0x81,0x48,0x93,0x09,0x04,0xfc, -0xce,0x86,0x01,0x47,0x01,0x26,0x17,0x05,0x00,0x00,0x13,0x05,0x25,0x54,0x3a,0x88, -0x05,0x27,0xbb,0xf7,0xc5,0x02,0x82,0x17,0x81,0x93,0xaa,0x97,0x83,0xc7,0x07,0x00, -0x23,0x80,0xf6,0x00,0x9b,0x87,0x05,0x00,0xbb,0xd5,0xc5,0x02,0x85,0x06,0xe3,0xf0, -0xc7,0xfe,0x63,0x8c,0x08,0x00,0x93,0x07,0x07,0xfd,0x33,0x87,0x87,0x00,0x93,0x07, -0xd0,0x02,0x23,0x08,0xf7,0xfe,0x1b,0x07,0x28,0x00,0x63,0x56,0xe0,0x02,0x13,0x09, -0x04,0xfc,0x3a,0x99,0xfd,0x19,0xba,0x99,0x7d,0x37,0x02,0x17,0x01,0x93,0xb3,0x89, -0xe9,0x40,0x83,0x45,0xf9,0xff,0x26,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0xf5, -0x7d,0x19,0xe3,0x18,0x39,0xff,0xe2,0x70,0x42,0x74,0xa2,0x74,0x02,0x79,0xe2,0x69, -0x21,0x61,0x82,0x80,0xbb,0x05,0xb0,0x40,0x85,0x48,0x8d,0xbf,0x19,0x71,0x86,0xfc, -0xa2,0xf8,0xa6,0xf4,0xca,0xf0,0xce,0xec,0xd2,0xe8,0xd6,0xe4,0xda,0xe0,0x5e,0xfc, -0x62,0xf8,0x66,0xf4,0x6a,0xf0,0x6e,0xec,0x00,0x01,0x03,0xc9,0x05,0x00,0x63,0x0f, -0x09,0x18,0xaa,0x8a,0x32,0x8b,0x93,0x84,0x15,0x00,0x81,0x49,0x13,0x0a,0x50,0x02, -0x55,0x4c,0x97,0x0c,0x00,0x00,0x93,0x8c,0xec,0x42,0x93,0x0d,0x80,0x02,0x41,0x4d, -0x97,0x0b,0x00,0x00,0x93,0x8b,0x8b,0x47,0x39,0xa8,0xca,0x85,0x56,0x85,0x97,0x00, -0x00,0x00,0xe7,0x80,0x20,0xee,0x19,0xa0,0x63,0x8d,0x49,0x01,0x85,0x04,0x03,0xc9, -0xf4,0xff,0x63,0x0d,0x09,0x14,0xe3,0x99,0x09,0xfe,0xe3,0x10,0x49,0xff,0xd2,0x89, -0xf5,0xb7,0x63,0x0c,0x49,0x11,0x9b,0x07,0xd9,0xf9,0x93,0xf7,0xf7,0x0f,0x63,0x6e, -0xfc,0x10,0x9b,0x07,0xd9,0xf9,0x13,0xf7,0xf7,0x0f,0x63,0x68,0xec,0x10,0x93,0x17, -0x27,0x00,0xe6,0x97,0x9c,0x43,0xe6,0x97,0x82,0x87,0x13,0x09,0x8b,0x00,0x85,0x46, -0x29,0x46,0x83,0x25,0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xa0,0xea, -0x4a,0x8b,0x81,0x49,0x65,0xb7,0x13,0x09,0x8b,0x00,0x81,0x46,0x29,0x46,0x83,0x25, -0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xe0,0xe8,0x4a,0x8b,0x81,0x49, -0x71,0xb7,0x13,0x09,0x8b,0x00,0x81,0x46,0x6a,0x86,0x83,0x25,0x0b,0x00,0x56,0x85, -0x97,0x00,0x00,0x00,0xe7,0x80,0x20,0xe7,0x4a,0x8b,0x81,0x49,0x85,0xbf,0x93,0x07, -0x8b,0x00,0x23,0x34,0xf4,0xf8,0x83,0x39,0x0b,0x00,0x93,0x05,0x00,0x03,0x56,0x85, -0x97,0x00,0x00,0x00,0xe7,0x80,0x00,0xe3,0x93,0x05,0x80,0x07,0x56,0x85,0x97,0x00, -0x00,0x00,0xe7,0x80,0x20,0xe2,0x6a,0x89,0x93,0xd7,0xc9,0x03,0xde,0x97,0x83,0xc5, -0x07,0x00,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0xe0,0x92,0x09,0x7d,0x39, -0xe3,0x14,0x09,0xfe,0x03,0x3b,0x84,0xf8,0x81,0x49,0x0d,0xb7,0x13,0x09,0x8b,0x00, -0x83,0x39,0x0b,0x00,0x63,0x81,0x09,0x02,0x83,0xc5,0x09,0x00,0xad,0xc5,0x56,0x85, -0x97,0x00,0x00,0x00,0xe7,0x80,0x00,0xde,0x85,0x09,0x83,0xc5,0x09,0x00,0xe5,0xf9, -0x4a,0x8b,0x81,0x49,0xe5,0xbd,0x97,0x09,0x00,0x00,0x93,0x89,0x29,0x2f,0xee,0x85, -0xf9,0xbf,0x13,0x09,0x8b,0x00,0x83,0x45,0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00, -0xe7,0x80,0x40,0xdb,0x4a,0x8b,0x81,0x49,0xd1,0xbd,0xd2,0x85,0x56,0x85,0x97,0x00, -0x00,0x00,0xe7,0x80,0x20,0xda,0x81,0x49,0xd1,0xb5,0xd2,0x85,0x56,0x85,0x97,0x00, -0x00,0x00,0xe7,0x80,0x20,0xd9,0xca,0x85,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, -0x60,0xd8,0x81,0x49,0x65,0xb5,0x4a,0x8b,0x81,0x49,0x4d,0xb5,0xe6,0x70,0x46,0x74, -0xa6,0x74,0x06,0x79,0xe6,0x69,0x46,0x6a,0xa6,0x6a,0x06,0x6b,0xe2,0x7b,0x42,0x7c, -0xa2,0x7c,0x02,0x7d,0xe2,0x6d,0x09,0x61,0x82,0x80,0x5d,0x71,0x06,0xec,0x22,0xe8, -0x00,0x10,0x10,0xe0,0x14,0xe4,0x18,0xe8,0x1c,0xec,0x23,0x30,0x04,0x03,0x23,0x34, -0x14,0x03,0x22,0x86,0x23,0x34,0x84,0xfe,0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0xe0, -0xe2,0x60,0x42,0x64,0x61,0x61,0x82,0x80,0x1d,0x71,0x06,0xec,0x22,0xe8,0x00,0x10, -0x0c,0xe4,0x10,0xe8,0x14,0xec,0x18,0xf0,0x1c,0xf4,0x23,0x38,0x04,0x03,0x23,0x3c, -0x14,0x03,0x13,0x06,0x84,0x00,0x23,0x34,0xc4,0xfe,0xaa,0x85,0x05,0x45,0x97,0x00, -0x00,0x00,0xe7,0x80,0xe0,0xdc,0xe2,0x60,0x42,0x64,0x25,0x61,0x82,0x80,0x41,0x11, -0x22,0xe4,0x00,0x08,0x93,0x06,0x05,0xff,0x97,0x07,0x00,0x00,0x83,0xb7,0x07,0x2c, -0x2d,0xa0,0x18,0x46,0x2d,0x9f,0x23,0x2c,0xe5,0xfe,0x98,0x63,0x10,0x63,0x3d,0xa8, -0x03,0x27,0x85,0xff,0x31,0x9f,0x98,0xc7,0x83,0x36,0x05,0xff,0x91,0xa0,0x98,0x63, -0x63,0xe4,0xe7,0x00,0x63,0xea,0xe6,0x00,0xba,0x87,0xe3,0xfa,0xd7,0xfe,0x98,0x63, -0x63,0xe4,0xe6,0x00,0xe3,0xea,0xe7,0xfe,0x83,0x25,0x85,0xff,0x90,0x63,0x13,0x98, -0x05,0x02,0x13,0x57,0xc8,0x01,0x36,0x97,0xe3,0x0d,0xe6,0xfa,0x23,0x38,0xc5,0xfe, -0x90,0x47,0x93,0x15,0x06,0x02,0x13,0xd7,0xc5,0x01,0x3e,0x97,0xe3,0x8a,0xe6,0xfa, -0x94,0xe3,0x17,0x07,0x00,0x00,0x23,0x3b,0xf7,0x24,0x22,0x64,0x41,0x01,0x82,0x80, -0x39,0x71,0x06,0xfc,0x22,0xf8,0x26,0xf4,0x4a,0xf0,0x4e,0xec,0x52,0xe8,0x56,0xe4, -0x5a,0xe0,0x80,0x00,0x93,0x14,0x05,0x02,0x81,0x90,0xbd,0x04,0x91,0x80,0x1b,0x8a, -0x14,0x00,0x85,0x04,0x17,0x05,0x00,0x00,0x03,0x35,0x45,0x22,0x15,0xc5,0x1c,0x61, -0x98,0x47,0x63,0x71,0x97,0x04,0xd2,0x89,0x1b,0x07,0x0a,0x00,0x85,0x66,0x63,0x73, -0xd7,0x00,0x85,0x69,0x1b,0x8b,0x09,0x00,0x9b,0x99,0x49,0x00,0x17,0x09,0x00,0x00, -0x13,0x09,0xc9,0x1f,0xfd,0x5a,0xa5,0xa8,0x97,0x07,0x00,0x00,0x93,0x87,0x07,0x1f, -0x17,0x07,0x00,0x00,0x13,0x07,0x07,0x1f,0x98,0xe3,0x98,0xe7,0x23,0xa8,0x07,0x00, -0xba,0x87,0xd1,0xb7,0x63,0x8c,0xe4,0x02,0x3b,0x07,0x47,0x41,0x98,0xc7,0x93,0x16, -0x07,0x02,0x13,0xd7,0xc6,0x01,0xba,0x97,0x23,0xa4,0x47,0x01,0x17,0x07,0x00,0x00, -0x23,0x3e,0xa7,0x1a,0x13,0x85,0x07,0x01,0xe2,0x70,0x42,0x74,0xa2,0x74,0x02,0x79, -0xe2,0x69,0x42,0x6a,0xa2,0x6a,0x02,0x6b,0x21,0x61,0x82,0x80,0x98,0x63,0x18,0xe1, -0xf1,0xbf,0x23,0x24,0x65,0x01,0x41,0x05,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0xec, -0x03,0x35,0x09,0x00,0x71,0xd9,0x1c,0x61,0x98,0x47,0xe3,0x75,0x97,0xfa,0x03,0x37, -0x09,0x00,0x3e,0x85,0xe3,0x19,0xf7,0xfe,0x4e,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, -0x00,0xb2,0xe3,0x18,0x55,0xfd,0x01,0x45,0x45,0xbf,0x00,0x00,0x00,0x00,0x00,0x00, -0x69,0x6e,0x69,0x74,0x3a,0x20,0x73,0x74,0x61,0x72,0x74,0x69,0x6e,0x67,0x20,0x73, -0x68,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6e,0x69,0x74,0x3a,0x20,0x66,0x6f, -0x72,0x6b,0x20,0x66,0x61,0x69,0x6c,0x65,0x64,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, -0x65,0x78,0x65,0x63,0x75,0x74,0x69,0x6e,0x67,0x20,0x74,0x65,0x73,0x74,0x20,0x25, -0x73,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6e,0x69,0x74,0x3a,0x20,0x65,0x78, -0x65,0x63,0x20,0x25,0x73,0x20,0x66,0x61,0x69,0x6c,0x65,0x64,0x0a,0x00,0x00,0x00, -0x69,0x6e,0x69,0x74,0x3a,0x20,0x77,0x61,0x69,0x74,0x20,0x72,0x65,0x74,0x75,0x72, -0x6e,0x65,0x64,0x20,0x61,0x6e,0x20,0x65,0x72,0x72,0x6f,0x72,0x0a,0x00,0x00,0x00, -0x67,0x65,0x74,0x63,0x77,0x64,0x00,0x00,0x77,0x72,0x69,0x74,0x65,0x00,0x00,0x00, -0x67,0x65,0x74,0x70,0x69,0x64,0x00,0x00,0x74,0x69,0x6d,0x65,0x73,0x00,0x00,0x00, -0x75,0x6e,0x61,0x6d,0x65,0x00,0x00,0x00,0x28,0x6e,0x75,0x6c,0x6c,0x29,0x00,0x00, -0x12,0xfd,0xff,0xff,0x3a,0xfc,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff, -0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff, -0x3a,0xfd,0xff,0xff,0x56,0xfc,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff, -0x3a,0xfd,0xff,0xff,0x8e,0xfc,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff, -0xdc,0xfc,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff,0x3a,0xfd,0xff,0xff, -0x3a,0xfd,0xff,0xff,0x72,0xfc,0xff,0xff,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, -0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0xc8,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0xd8,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0xb0,0x03,0x73,0x00,0x00,0x00,0x82,0x80, +0x93,0x08,0xf0,0x03,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x00,0x04,0x73,0x00, +0x00,0x00,0x82,0x80,0x93,0x08,0x90,0x03,0x73,0x00,0x00,0x00,0x82,0x80,0x99,0x48, +0x73,0x00,0x00,0x00,0x82,0x80,0x9d,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xbd,0x48, +0x73,0x00,0x00,0x00,0x82,0x80,0xa1,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xd1,0x48, +0x73,0x00,0x00,0x00,0x82,0x80,0xa5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xa9,0x48, +0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0xc0,0x0a,0x73,0x00,0x00,0x00,0x82,0x80, +0xb1,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xb5,0x48,0x73,0x00,0x00,0x00,0x82,0x80, +0xb9,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xd9,0x48,0x73,0x00,0x00,0x00,0x82,0x80, +0xdd,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xe1,0x48,0x73,0x00,0x00,0x00,0x82,0x80, +0xc5,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xe5,0x48,0x73,0x00,0x00,0x00,0x82,0x80, +0xc9,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0xcd,0x48,0x73,0x00,0x00,0x00,0x82,0x80, +0xe9,0x48,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x90,0x09,0x73,0x00,0x00,0x00, +0x82,0x80,0x93,0x08,0x00,0x0a,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0xf0,0x1f, +0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x40,0x10,0x73,0x00,0x00,0x00,0x82,0x80, +0x93,0x08,0xc0,0x0d,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0xd0,0x0d,0x73,0x00, +0x00,0x00,0x82,0x80,0x93,0x08,0xd0,0x0a,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08, +0xc0,0x07,0x73,0x00,0x00,0x00,0x82,0x80,0x93,0x08,0x90,0x0a,0x73,0x00,0x00,0x00, +0x82,0x80,0x93,0x08,0x50,0x06,0x73,0x00,0x00,0x00,0x82,0x80,0x01,0x11,0x06,0xec, +0x22,0xe8,0x00,0x10,0xa3,0x07,0xb4,0xfe,0x05,0x46,0x93,0x05,0xf4,0xfe,0x97,0x00, +0x00,0x00,0xe7,0x80,0xc0,0xed,0xe2,0x60,0x42,0x64,0x05,0x61,0x82,0x80,0x39,0x71, +0x06,0xfc,0x22,0xf8,0x26,0xf4,0x4a,0xf0,0x4e,0xec,0x80,0x00,0xaa,0x84,0x99,0xc2, +0x63,0xc8,0x05,0x08,0x81,0x25,0x81,0x48,0x93,0x09,0x04,0xfc,0xce,0x86,0x01,0x47, +0x01,0x26,0x17,0x05,0x00,0x00,0x13,0x05,0xe5,0x59,0x3a,0x88,0x05,0x27,0xbb,0xf7, +0xc5,0x02,0x82,0x17,0x81,0x93,0xaa,0x97,0x83,0xc7,0x07,0x00,0x23,0x80,0xf6,0x00, +0x9b,0x87,0x05,0x00,0xbb,0xd5,0xc5,0x02,0x85,0x06,0xe3,0xf0,0xc7,0xfe,0x63,0x8c, +0x08,0x00,0x93,0x07,0x07,0xfd,0x33,0x87,0x87,0x00,0x93,0x07,0xd0,0x02,0x23,0x08, +0xf7,0xfe,0x1b,0x07,0x28,0x00,0x63,0x56,0xe0,0x02,0x13,0x09,0x04,0xfc,0x3a,0x99, +0xfd,0x19,0xba,0x99,0x7d,0x37,0x02,0x17,0x01,0x93,0xb3,0x89,0xe9,0x40,0x83,0x45, +0xf9,0xff,0x26,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0x80,0xf5,0x7d,0x19,0xe3,0x18, +0x39,0xff,0xe2,0x70,0x42,0x74,0xa2,0x74,0x02,0x79,0xe2,0x69,0x21,0x61,0x82,0x80, +0xbb,0x05,0xb0,0x40,0x85,0x48,0x8d,0xbf,0x19,0x71,0x86,0xfc,0xa2,0xf8,0xa6,0xf4, +0xca,0xf0,0xce,0xec,0xd2,0xe8,0xd6,0xe4,0xda,0xe0,0x5e,0xfc,0x62,0xf8,0x66,0xf4, +0x6a,0xf0,0x6e,0xec,0x00,0x01,0x03,0xc9,0x05,0x00,0x63,0x0f,0x09,0x18,0xaa,0x8a, +0x32,0x8b,0x93,0x84,0x15,0x00,0x81,0x49,0x13,0x0a,0x50,0x02,0x55,0x4c,0x97,0x0c, +0x00,0x00,0x93,0x8c,0xac,0x48,0x93,0x0d,0x80,0x02,0x41,0x4d,0x97,0x0b,0x00,0x00, +0x93,0x8b,0x4b,0x4d,0x39,0xa8,0xca,0x85,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, +0x20,0xee,0x19,0xa0,0x63,0x8d,0x49,0x01,0x85,0x04,0x03,0xc9,0xf4,0xff,0x63,0x0d, +0x09,0x14,0xe3,0x99,0x09,0xfe,0xe3,0x10,0x49,0xff,0xd2,0x89,0xf5,0xb7,0x63,0x0c, +0x49,0x11,0x9b,0x07,0xd9,0xf9,0x93,0xf7,0xf7,0x0f,0x63,0x6e,0xfc,0x10,0x9b,0x07, +0xd9,0xf9,0x13,0xf7,0xf7,0x0f,0x63,0x68,0xec,0x10,0x93,0x17,0x27,0x00,0xe6,0x97, +0x9c,0x43,0xe6,0x97,0x82,0x87,0x13,0x09,0x8b,0x00,0x85,0x46,0x29,0x46,0x83,0x25, +0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xa0,0xea,0x4a,0x8b,0x81,0x49, +0x65,0xb7,0x13,0x09,0x8b,0x00,0x81,0x46,0x29,0x46,0x83,0x25,0x0b,0x00,0x56,0x85, +0x97,0x00,0x00,0x00,0xe7,0x80,0xe0,0xe8,0x4a,0x8b,0x81,0x49,0x71,0xb7,0x13,0x09, +0x8b,0x00,0x81,0x46,0x6a,0x86,0x83,0x25,0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00, +0xe7,0x80,0x20,0xe7,0x4a,0x8b,0x81,0x49,0x85,0xbf,0x93,0x07,0x8b,0x00,0x23,0x34, +0xf4,0xf8,0x83,0x39,0x0b,0x00,0x93,0x05,0x00,0x03,0x56,0x85,0x97,0x00,0x00,0x00, +0xe7,0x80,0x00,0xe3,0x93,0x05,0x80,0x07,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, +0x20,0xe2,0x6a,0x89,0x93,0xd7,0xc9,0x03,0xde,0x97,0x83,0xc5,0x07,0x00,0x56,0x85, +0x97,0x00,0x00,0x00,0xe7,0x80,0xc0,0xe0,0x92,0x09,0x7d,0x39,0xe3,0x14,0x09,0xfe, +0x03,0x3b,0x84,0xf8,0x81,0x49,0x0d,0xb7,0x13,0x09,0x8b,0x00,0x83,0x39,0x0b,0x00, +0x63,0x81,0x09,0x02,0x83,0xc5,0x09,0x00,0xad,0xc5,0x56,0x85,0x97,0x00,0x00,0x00, +0xe7,0x80,0x00,0xde,0x85,0x09,0x83,0xc5,0x09,0x00,0xe5,0xf9,0x4a,0x8b,0x81,0x49, +0xe5,0xbd,0x97,0x09,0x00,0x00,0x93,0x89,0xe9,0x34,0xee,0x85,0xf9,0xbf,0x13,0x09, +0x8b,0x00,0x83,0x45,0x0b,0x00,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0xdb, +0x4a,0x8b,0x81,0x49,0xd1,0xbd,0xd2,0x85,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, +0x20,0xda,0x81,0x49,0xd1,0xb5,0xd2,0x85,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80, +0x20,0xd9,0xca,0x85,0x56,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0xd8,0x81,0x49, +0x65,0xb5,0x4a,0x8b,0x81,0x49,0x4d,0xb5,0xe6,0x70,0x46,0x74,0xa6,0x74,0x06,0x79, +0xe6,0x69,0x46,0x6a,0xa6,0x6a,0x06,0x6b,0xe2,0x7b,0x42,0x7c,0xa2,0x7c,0x02,0x7d, +0xe2,0x6d,0x09,0x61,0x82,0x80,0x5d,0x71,0x06,0xec,0x22,0xe8,0x00,0x10,0x10,0xe0, +0x14,0xe4,0x18,0xe8,0x1c,0xec,0x23,0x30,0x04,0x03,0x23,0x34,0x14,0x03,0x22,0x86, +0x23,0x34,0x84,0xfe,0x97,0x00,0x00,0x00,0xe7,0x80,0x40,0xe0,0xe2,0x60,0x42,0x64, +0x61,0x61,0x82,0x80,0x1d,0x71,0x06,0xec,0x22,0xe8,0x00,0x10,0x0c,0xe4,0x10,0xe8, +0x14,0xec,0x18,0xf0,0x1c,0xf4,0x23,0x38,0x04,0x03,0x23,0x3c,0x14,0x03,0x13,0x06, +0x84,0x00,0x23,0x34,0xc4,0xfe,0xaa,0x85,0x05,0x45,0x97,0x00,0x00,0x00,0xe7,0x80, +0xe0,0xdc,0xe2,0x60,0x42,0x64,0x25,0x61,0x82,0x80,0x41,0x11,0x22,0xe4,0x00,0x08, +0x93,0x06,0x05,0xff,0x97,0x07,0x00,0x00,0x83,0xb7,0x47,0x37,0x2d,0xa0,0x18,0x46, +0x2d,0x9f,0x23,0x2c,0xe5,0xfe,0x98,0x63,0x10,0x63,0x3d,0xa8,0x03,0x27,0x85,0xff, +0x31,0x9f,0x98,0xc7,0x83,0x36,0x05,0xff,0x91,0xa0,0x98,0x63,0x63,0xe4,0xe7,0x00, +0x63,0xea,0xe6,0x00,0xba,0x87,0xe3,0xfa,0xd7,0xfe,0x98,0x63,0x63,0xe4,0xe6,0x00, +0xe3,0xea,0xe7,0xfe,0x83,0x25,0x85,0xff,0x90,0x63,0x13,0x98,0x05,0x02,0x13,0x57, +0xc8,0x01,0x36,0x97,0xe3,0x0d,0xe6,0xfa,0x23,0x38,0xc5,0xfe,0x90,0x47,0x93,0x15, +0x06,0x02,0x13,0xd7,0xc5,0x01,0x3e,0x97,0xe3,0x8a,0xe6,0xfa,0x94,0xe3,0x17,0x07, +0x00,0x00,0x23,0x35,0xf7,0x30,0x22,0x64,0x41,0x01,0x82,0x80,0x39,0x71,0x06,0xfc, +0x22,0xf8,0x26,0xf4,0x4a,0xf0,0x4e,0xec,0x52,0xe8,0x56,0xe4,0x5a,0xe0,0x80,0x00, +0x93,0x14,0x05,0x02,0x81,0x90,0xbd,0x04,0x91,0x80,0x1b,0x8a,0x14,0x00,0x85,0x04, +0x17,0x05,0x00,0x00,0x03,0x35,0x85,0x2d,0x15,0xc5,0x1c,0x61,0x98,0x47,0x63,0x71, +0x97,0x04,0xd2,0x89,0x1b,0x07,0x0a,0x00,0x85,0x66,0x63,0x73,0xd7,0x00,0x85,0x69, +0x1b,0x8b,0x09,0x00,0x9b,0x99,0x49,0x00,0x17,0x09,0x00,0x00,0x13,0x09,0x09,0x2b, +0xfd,0x5a,0xa5,0xa8,0x97,0x07,0x00,0x00,0x93,0x87,0x47,0x2a,0x17,0x07,0x00,0x00, +0x13,0x07,0x47,0x2a,0x98,0xe3,0x98,0xe7,0x23,0xa8,0x07,0x00,0xba,0x87,0xd1,0xb7, +0x63,0x8c,0xe4,0x02,0x3b,0x07,0x47,0x41,0x98,0xc7,0x93,0x16,0x07,0x02,0x13,0xd7, +0xc6,0x01,0xba,0x97,0x23,0xa4,0x47,0x01,0x17,0x07,0x00,0x00,0x23,0x38,0xa7,0x26, +0x13,0x85,0x07,0x01,0xe2,0x70,0x42,0x74,0xa2,0x74,0x02,0x79,0xe2,0x69,0x42,0x6a, +0xa2,0x6a,0x02,0x6b,0x21,0x61,0x82,0x80,0x98,0x63,0x18,0xe1,0xf1,0xbf,0x23,0x24, +0x65,0x01,0x41,0x05,0x97,0x00,0x00,0x00,0xe7,0x80,0x60,0xec,0x03,0x35,0x09,0x00, +0x71,0xd9,0x1c,0x61,0x98,0x47,0xe3,0x75,0x97,0xfa,0x03,0x37,0x09,0x00,0x3e,0x85, +0xe3,0x19,0xf7,0xfe,0x4e,0x85,0x97,0x00,0x00,0x00,0xe7,0x80,0xa0,0xad,0xe3,0x18, +0x55,0xfd,0x01,0x45,0x45,0xbf,0x00,0x00,0x69,0x6e,0x69,0x74,0x3a,0x20,0x73,0x74, +0x61,0x72,0x74,0x69,0x6e,0x67,0x20,0x73,0x68,0x65,0x6c,0x6c,0x0a,0x00,0x00,0x00, +0x69,0x6e,0x69,0x74,0x3a,0x20,0x66,0x6f,0x72,0x6b,0x20,0x66,0x61,0x69,0x6c,0x75, +0x72,0x65,0x0a,0x00,0x00,0x00,0x00,0x00,0x65,0x78,0x65,0x63,0x75,0x74,0x69,0x6e, +0x67,0x20,0x74,0x65,0x73,0x74,0x73,0x20,0x25,0x73,0x0a,0x00,0x00,0x00,0x00,0x00, +0x69,0x6e,0x69,0x74,0x3a,0x20,0x65,0x78,0x65,0x63,0x20,0x25,0x73,0x20,0x66,0x61, +0x69,0x6c,0x75,0x72,0x65,0x0a,0x00,0x00,0x69,0x6e,0x69,0x74,0x3a,0x20,0x77,0x61, +0x69,0x74,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x65,0x64,0x20,0x61,0x6e,0x20,0x65, +0x72,0x72,0x6f,0x72,0x0a,0x00,0x00,0x00,0x67,0x65,0x74,0x63,0x77,0x64,0x00,0x00, +0x77,0x72,0x69,0x74,0x65,0x00,0x00,0x00,0x67,0x65,0x74,0x70,0x69,0x64,0x00,0x00, +0x74,0x69,0x6d,0x65,0x73,0x00,0x00,0x00,0x75,0x6e,0x61,0x6d,0x65,0x00,0x00,0x00, +0x77,0x61,0x69,0x74,0x00,0x00,0x00,0x00,0x63,0x6c,0x6f,0x6e,0x65,0x00,0x00,0x00, +0x70,0x69,0x70,0x65,0x00,0x00,0x00,0x00,0x66,0x6f,0x72,0x6b,0x00,0x00,0x00,0x00, +0x65,0x78,0x65,0x63,0x76,0x65,0x00,0x00,0x67,0x65,0x74,0x70,0x70,0x69,0x64,0x00, +0x65,0x78,0x69,0x74,0x00,0x00,0x00,0x00,0x79,0x69,0x65,0x6c,0x64,0x00,0x00,0x00, +0x77,0x61,0x69,0x74,0x70,0x69,0x64,0x00,0x67,0x65,0x74,0x74,0x69,0x6d,0x65,0x6f, +0x66,0x64,0x61,0x79,0x00,0x00,0x00,0x00,0x73,0x6c,0x65,0x65,0x70,0x00,0x00,0x00, +0x28,0x6e,0x75,0x6c,0x6c,0x29,0x00,0x00,0xb6,0xfc,0xff,0xff,0xde,0xfb,0xff,0xff, +0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff, +0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xfa,0xfb,0xff,0xff, +0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0x32,0xfc,0xff,0xff, +0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0x80,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff, +0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0xde,0xfc,0xff,0xff,0x16,0xfc,0xff,0xff, +0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x38,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x58,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x68,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x78,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, diff --git a/kernel/include/proc.h b/kernel/include/proc.h index c5db403..1fbf5da 100644 --- a/kernel/include/proc.h +++ b/kernel/include/proc.h @@ -66,6 +66,10 @@ struct proc { char name[16]; // Process name (debugging) int tmask; // trace mask struct tms tms; // time info + + uint64 uticks; // 在用户æ€è·‘了多少 tick + uint64 sticks; // åœ¨å†…æ ¸æ€è·‘了多少 tick + uint64 start_ticks; // è¿›ç¨‹åˆ›å»ºæ—¶çš„å½“å‰ ticks,用æ¥ç®— elapsed }; void reg_info(void); @@ -93,5 +97,8 @@ int either_copyin(void *dst, int user_src, uint64 src, uint64 len); void procdump(void); uint64 procnum(void); void test_proc_init(int); +int wait4(int, uint64, uint64); +int clone(uint64); + #endif \ No newline at end of file diff --git a/kernel/include/sysnum.h b/kernel/include/sysnum.h index 9365e62..58e91d7 100644 --- a/kernel/include/sysnum.h +++ b/kernel/include/sysnum.h @@ -4,8 +4,6 @@ // System call numbers #define SYS_fork 1 #define SYS_wait 3 -#define SYS_pipe 4 -#define SYS_read 5 #define SYS_kill 6 #define SYS_exec 7 #define SYS_fstat 8 @@ -19,17 +17,27 @@ #define SYS_trace 18 #define SYS_sysinfo 19 #define SYS_mkdir 20 -#define SYS_close 21 #define SYS_test_proc 22 #define SYS_dev 23 #define SYS_readdir 24 #define SYS_remove 25 #define SYS_rename 26 +#define SYS_close 57 +#define SYS_pipe 59 +#define SYS_read 63 #define SYS_write 64 #define SYS_exit 93 +#define SYS_nanosleep 101 +#define SYS_sched_yield 124 #define SYS_times 153 #define SYS_uname 160 +#define SYS_gettimeofday 169 #define SYS_getpid 172 -#define SYS_shutdown 255 +#define SYS_getppid 173 +#define SYS_clone 220 +#define SYS_execve 221 +#define SYS_wait4 260 +#define SYS_shutdown 511 + #endif \ No newline at end of file diff --git a/kernel/include/time.h b/kernel/include/time.h new file mode 100644 index 0000000..b09c8a3 --- /dev/null +++ b/kernel/include/time.h @@ -0,0 +1,9 @@ +#ifndef __TIME_H +#define __TIME_H + +struct timespec { + long tv_sec; + long tv_usec; +}; + +#endif diff --git a/kernel/include/types.h b/kernel/include/types.h index a0df747..ea7b8d5 100644 --- a/kernel/include/types.h +++ b/kernel/include/types.h @@ -16,6 +16,8 @@ typedef unsigned long clock_t; typedef unsigned long uintptr_t; typedef uint64 pde_t; +typedef int pid_t; + // #define NULL ((void *)0) #define NULL 0 diff --git a/kernel/proc.c b/kernel/proc.c index 882a9b9..093549d 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -804,3 +804,88 @@ procnum(void) return num; } +int +wait4(int pid, uint64 addr, uint64 options) +{ + struct proc *np; + int havekids; + struct proc *p = myproc(); + + acquire(&p->lock); + + for (;;) { + havekids = 0; + for (np = proc; np < &proc[NPROC]; np++) { + if (np->parent == p) { + acquire(&np->lock); + if (np->pid == pid) { + havekids = 1; + if (np->state == ZOMBIE) { + int exitstatus = np->xstate; + exitstatus = exitstatus << 8; + if(addr != 0 && copyout2(addr, (char *)&exitstatus, sizeof(exitstatus)) < 0) { + release(&np->lock); + release(&p->lock); + return -1; + } + freeproc(np); + release(&np->lock); + release(&p->lock); + return pid; + } + } + release(&np->lock); + } + } + + if (havekids == 0 || p->killed){ + release(&p->lock); + return -1; + } + + sleep(p, &p->lock); + } +} + +int +clone(uint64 stack) +{ + int i, pid; + struct proc *np; + struct proc *p = myproc(); + + if ((np = allocproc()) == NULL) + return -1; + + if (uvmcopy(p->pagetable, np->pagetable, np->kpagetable, p->sz) < 0) { + freeproc(np); + release(&np->lock); + return -1; + } + + np->sz = p->sz; + + np->parent = p; + + np->tmask = p->tmask; + + *(np->trapframe) = *(p->trapframe); + + np->trapframe->a0 = 0; + np->trapframe->sp = stack; + + for (i = 0; i < NOFILE; i++) + if (p->ofile[i]) + np->ofile[i] = filedup(p->ofile[i]); + np->cwd = edup(p->cwd); + + safestrcpy(np->name, p->name, sizeof(p->name)); + + pid = np->pid; + + np->state = RUNNABLE; + + release(&np->lock); + + return pid; +} diff --git a/kernel/syscall.c b/kernel/syscall.c index 9a260ac..d69ba86 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -128,6 +128,13 @@ extern uint64 sys_rename(void); extern uint64 sys_times(void); extern uint64 sys_uname(void); extern uint64 sys_shutdown(void); +extern uint64 sys_wait4(void); +extern uint64 sys_clone(void); +extern uint64 sys_execve(void); +extern uint64 sys_getppid(void); +extern uint64 sys_sched_yield(void); +extern uint64 sys_gettimeofday(void); +extern uint64 sys_nanosleep(void); static uint64 (*syscalls[])(void) = { [SYS_fork] sys_fork, @@ -159,6 +166,13 @@ static uint64 (*syscalls[])(void) = { [SYS_times] sys_times, [SYS_uname] sys_uname, [SYS_shutdown] sys_shutdown, + [SYS_wait4] sys_wait4, + [SYS_clone] sys_clone, + [SYS_execve] sys_execve, + [SYS_getppid] sys_getppid, + [SYS_sched_yield] sys_sched_yield, + [SYS_gettimeofday] sys_gettimeofday, + [SYS_nanosleep] sys_nanosleep, }; static char *sysnames[] = { @@ -190,7 +204,14 @@ static char *sysnames[] = { [SYS_rename] "rename", [SYS_times] "times", [SYS_uname] "uname", - [SYS_shutdown] "shutdown", + [SYS_shutdown] "shutdown", + [SYS_wait4] "wait4", + [SYS_clone] "clone", + [SYS_execve] "execve", + [SYS_getppid] "getppid", + [SYS_sched_yield] "sched_yield", + [SYS_gettimeofday] "gettimeofday", + [SYS_nanosleep] "nanosleep", }; void diff --git a/kernel/sysproc.c b/kernel/sysproc.c index c67b626..7852e7a 100644 --- a/kernel/sysproc.c +++ b/kernel/sysproc.c @@ -14,6 +14,7 @@ #include "include/tms.h" #include "include/utsname.h" #include "include/vm.h" +#include "include/time.h" extern int exec(char *path, char **argv); @@ -202,4 +203,136 @@ sys_shutdown(void) { sbi_shutdown(); return 0; -} \ No newline at end of file +} + +uint64 +sys_wait4(void) +{ + int pid; + uint64 addr; + int options; + if (argint(0, &pid) < 0 || argaddr(1, &addr) < 0 || argint(2, &options) < 0) + return -1; + if (pid == -1) + return wait(addr); + return wait4(pid,addr,options); +} + +uint64 +sys_clone(void){ + uint64 stack; + if (argaddr(1, (uint64*)&stack) < 0) + return -1; + if (stack == 0) + return fork(); + return clone(stack); +} + +uint64 +sys_execve(void) +{ + char path[FAT32_MAX_PATH], *argv[MAXARG], *envp[MAXARG]; + int i; + uint64 uargv, uenvp; + + if (argstr(0, path, FAT32_MAX_PATH) < 0 || argaddr(1, &uargv) < 0 || argaddr(2, &uenvp) < 0) + return -1; + + memset(argv, 0, sizeof(argv)); + + for (i = 0; ; i++) { + if (i >= NELEM(argv)) + goto bad; + if (fetchaddr(uargv + sizeof(uint64)*i, (uint64*)&argv[i]) < 0) + goto bad; + if (argv[i] == 0) + break; + } + + memset(envp, 0, sizeof(envp)); + + for (i = 0; ; i++) { + if (i >= NELEM(envp)) + goto bad; + if (fetchaddr(uenvp + sizeof(uint64)*i, (uint64*)&envp[i]) < 0) + goto bad; + if (envp[i] == 0) + break; + } + + return exec(path, argv); + +bad: + return -1; +} + +uint64 +sys_getppid(void) +{ + acquire(&myproc()->lock); + acquire(&myproc()->parent->lock); + release(&myproc()->parent->lock); + release(&myproc()->lock); + return myproc()->parent->pid; +} + +uint64 +sys_sched_yield(void) +{ + yield(); + return 0; +} + +uint64 +sys_gettimeofday(void) +{ + uint64 tv; + if (argaddr(0, &tv) < 0) + return -1; + + struct timespec t; + t.tv_sec = ticks / 1000; + t.tv_usec = (ticks % 1000) * 1000; + + if (copyout2(tv, (char*)&t, sizeof(t)) < 0) + return -1; + + return 0; +} + +uint64 +sys_nanosleep(void) +{ + uint64 req; + uint64 rem; + uint ticks0; + + if (argaddr(0, &req) < 0 || argaddr(1, &rem) < 0) + return -1; + + struct timespec *tv = (struct timespec *) req; + struct timespec tv1; + tv1.tv_usec = 0; + tv1.tv_sec = 0; + acquire(&tickslock); + ticks0 = ticks; + + while (ticks - ticks0 < tv->tv_sec) { + if (myproc()->killed) { + tv1.tv_sec = tv->tv_sec - (ticks - ticks0); + if(copyout2(rem, (char*)&tv1, sizeof(tv1)) < 0){ + release(&tickslock); + return -1; + } + release(&tickslock); + return -1; + } + sleep(&ticks, &tickslock); + } + + if (copyout2(rem, (char*)&tv1, sizeof(tv1)) < 0) + return -1; + + release(&tickslock); + return 0; +} diff --git a/xv6-user/init.c b/xv6-user/init.c index e8124ce..e5a2674 100644 --- a/xv6-user/init.c +++ b/xv6-user/init.c @@ -15,6 +15,17 @@ char *tests[] = { "getpid", "times", "uname", + "wait", + "clone", + "pipe", + "fork", + "execve", + "getppid", + "exit", + "yield", + "waitpid", + "gettimeofday", + "sleep", }; int counts = sizeof(tests) / sizeof(char *); diff --git a/xv6-user/user.h b/xv6-user/user.h index 579744b..f31216d 100644 --- a/xv6-user/user.h +++ b/xv6-user/user.h @@ -2,6 +2,7 @@ #include "kernel/include/stat.h" #include "kernel/include/fcntl.h" #include "kernel/include/tms.h" +#include "kernel/include/time.h" struct stat; struct rtcdate; @@ -58,4 +59,11 @@ void *memcpy(void *, const void *, uint); clock_t times(struct tms*); int uname(struct utsname*); -int shutdown(void); // call sbi_shutdown +int shutdown(void); +pid_t wait4(pid_t pid, int *status, int options); +pid_t clone(int flags, void *stack, pid_t *ptid, void *tls, pid_t *ctid); +int execve(const char *path, char *const argv[], char *const envp[]); +int getppid(void); +int sched_yield(void); +int gettimeofday(struct timespec *tv, int tz); +int nanosleep(const struct timespec *req, struct timespec *rem); diff --git a/xv6-user/usys.pl b/xv6-user/usys.pl index f29ec2e..91f2096 100644 --- a/xv6-user/usys.pl +++ b/xv6-user/usys.pl @@ -43,4 +43,11 @@ entry("sysinfo"); entry("rename"); entry("times"); entry("uname"); -entry("shutdown"); \ No newline at end of file +entry("shutdown"); +entry("wait4"); +entry("clone"); +entry("execve"); +entry("getppid"); +entry("sched_yield"); +entry("gettimeofday"); +entry("nanosleep"); -- GitLab