Skip to content

Commit

Permalink
Merge pull request #28 from Blue-club/chwangmin
Browse files Browse the repository at this point in the history
Chwangmin
  • Loading branch information
mywnajsldkf authored Jun 14, 2023
2 parents 5711918 + e38ad21 commit 2c75619
Show file tree
Hide file tree
Showing 206 changed files with 601 additions and 1,960 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Created by https://www.toptal.com/developers/gitignore/api/c
# Edit at https://www.toptal.com/developers/gitignore?templates=c

### C ###
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# git_ignore
*.bin

# End of https://www.toptal.com/developers/gitignore/api/c
20 changes: 20 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"files.associations": {
"syscall.h": "c",
"unistd.h": "c",
"intrinsic.h": "c",
"thread.h": "c",
"process.h": "c",
"gdt.h": "c",
"vga.h": "c",
"*.inc": "c",
"loader.h": "c",
"vaddr.h": "c",
"init.h": "c",
"flags.h": "c",
"filesys.h": "c",
"synch.h": "c",
"input.h": "c",
"off_t.h": "c"
}
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc-7 build active file",
"command": "/usr/bin/gcc-7",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
2 changes: 1 addition & 1 deletion include/threads/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define LOADER_BASE 0x7c00 /* Physical address of loader's base. */
#define LOADER_END 0x7e00 /* Physical address of end of loader. */

/* Physical address of kernel base. */
/* Virtual address of kernel base. */
#define LOADER_KERN_BASE 0x8004000000

/* Kernel virtual address at which all physical memory is mapped. */
Expand Down
26 changes: 26 additions & 0 deletions include/threads/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <list.h>
#include <stdint.h>
#include "threads/interrupt.h"
#include "threads/synch.h" // 이것을 추가해야 포인터를 쓸 수 있습니다.
#ifdef VM
#include "vm/vm.h"
#endif
Expand All @@ -28,6 +29,9 @@ typedef int tid_t;
#define PRI_DEFAULT 31 /* Default priority. */
#define PRI_MAX 63 /* Highest priority. */

#define FDT_PAGES 2
#define FDT_COUNT_LIMIT 128

/* A kernel thread or user process.
*
* Each thread structure is stored in its own 4 kB page. The
Expand Down Expand Up @@ -94,12 +98,28 @@ struct thread {
int64_t wakeup_tick; /* 해당 쓰레드가 깨어나야 할 tick을 저장할 필드 */
/* Shared between thread.c and synch.c. */
struct list_elem elem; /* List element. */

/*priority donation 관련 항목 추가*/
int init_priority; /* donation 이후 우선순위를 초기화하기 위해 초기값 저장 */
struct lock *wait_on_lock; /* 해당 스레드가 대기 하고 있는 lock자료구조의 주소를 저장 */
struct list donations; /* multiple donation 을 고려하기 위해 사용 */
struct list_elem donation_elem; /* multiple donation 을 고려하기 위해 사용 */

/*project 2 - SystemCall 항목 추가*/
int exit_status; /* exit 호출 시 종료 status */
struct file **fdt; /* 부모 프로세스의 디스크립터 */
int next_fd; /* 다음 디스크립트를 가리키는 테이블 번호 */

struct intr_frame parent_if; /* 프로세스 프로그램 메모리 적재 */
struct list child_list; /* 자식 리스트 */
struct list_elem child_elem; /* 자식 리스트 element */

struct semaphore load_sema; /* load 세마포어 */
struct semaphore exit_sema; /* exit 세마포어 */
struct semaphore wait_sema; /* wait 세마포어 */

struct file *running; // 현재 실행중인 파일

#ifdef USERPROG
/* Owned by userprog/process.c. */
uint64_t *pml4; /* Page map level 4 */
Expand Down Expand Up @@ -155,6 +175,10 @@ int64_t get_next_tick_to_awake(void);

void test_max_priority(void);
bool cmp_priority(const struct list_elem *a, const struct list_elem *b, void *aux UNUSED);
// project2
bool cmp_thread_priority(const struct list_elem *a, const struct list_elem *b, void *aux);
bool cmp_thread_ticks(const struct list_elem *a, const struct list_elem *b, void *aux);
// ---

void donate_priority(void);
void remove_with_lock(struct lock *lock);
Expand All @@ -163,4 +187,6 @@ void refresh_priority(void);
bool
thread_compare_donate_priority(const struct list_elem *x, const struct list_elem *y, void *aux UNUSED);

void preempt_priority(void);

#endif /* threads/thread.h */
8 changes: 7 additions & 1 deletion include/userprog/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ int process_exec (void *f_name);
int process_wait (tid_t);
void process_exit (void);
void process_activate (struct thread *next);

/* project 2 */
void argument_stack(char **argv, int argc, void **rsp);
struct thread *get_child_process(int pid);
int process_add_file(struct file *f);
struct file *process_get_file(int fd);
void process_close_file(int fd);
struct thread *get_child_process(int pid);
#endif /* userprog/process.h */
3 changes: 2 additions & 1 deletion include/userprog/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define USERPROG_SYSCALL_H

void syscall_init (void);
struct lock filesys_lock;

#endif /* userprog/syscall.h */
#endif /* userprog/syscall.h */
1 change: 1 addition & 0 deletions lib/user/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
int main (int, char *[]);
void _start (int argc, char *argv[]);

// user program의 진입점이다.
void
_start (int argc, char *argv[]) {
exit (main (argc, argv));
Expand Down
Binary file added output/test
Binary file not shown.
17 changes: 17 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>

int main()
{asdfsafkn;adfna;nf;
long num = 4613937818241073152;
long* ptr = &num;
long** dptr = &ptr;
long*** tptr = &dptr;

printf("\n abcd~~ abcd~~~ 0x%02X \n", *(long **)dptr);
printf("\n abcd~~ abcd~~~ 0x%02X \n", **(long **)dptr);
printf("\n abcd~~ abcd~~~ 0x%02X \n", **(long ***)dptr);
printf("\n abcd~~ abcd~~~ 0x%02X \n", ***(long ***)dptr);

//int aList[10] = {1,2,3,4,5,6,7,8,9,10};
return 0;
}
64 changes: 0 additions & 64 deletions threads/build/Makefile

This file was deleted.

9 changes: 0 additions & 9 deletions threads/build/devices/disk.d

This file was deleted.

Binary file removed threads/build/devices/disk.o
Binary file not shown.
6 changes: 0 additions & 6 deletions threads/build/devices/input.d

This file was deleted.

Binary file removed threads/build/devices/input.o
Binary file not shown.
5 changes: 0 additions & 5 deletions threads/build/devices/intq.d

This file was deleted.

Binary file removed threads/build/devices/intq.o
Binary file not shown.
7 changes: 0 additions & 7 deletions threads/build/devices/kbd.d

This file was deleted.

Binary file removed threads/build/devices/kbd.o
Binary file not shown.
8 changes: 0 additions & 8 deletions threads/build/devices/serial.d

This file was deleted.

Binary file removed threads/build/devices/serial.o
Binary file not shown.
8 changes: 0 additions & 8 deletions threads/build/devices/timer.d

This file was deleted.

Binary file removed threads/build/devices/timer.o
Binary file not shown.
6 changes: 0 additions & 6 deletions threads/build/devices/vga.d

This file was deleted.

Binary file removed threads/build/devices/vga.o
Binary file not shown.
Binary file removed threads/build/kernel.bin
Binary file not shown.
Binary file removed threads/build/kernel.o
Binary file not shown.
1 change: 0 additions & 1 deletion threads/build/lib/arithmetic.d

This file was deleted.

Binary file removed threads/build/lib/arithmetic.o
Binary file not shown.
5 changes: 0 additions & 5 deletions threads/build/lib/debug.d

This file was deleted.

Binary file removed threads/build/lib/debug.o
Binary file not shown.
7 changes: 0 additions & 7 deletions threads/build/lib/kernel/bitmap.d

This file was deleted.

Binary file removed threads/build/lib/kernel/bitmap.o
Binary file not shown.
8 changes: 0 additions & 8 deletions threads/build/lib/kernel/console.d

This file was deleted.

Binary file removed threads/build/lib/kernel/console.o
Binary file not shown.
7 changes: 0 additions & 7 deletions threads/build/lib/kernel/debug.d

This file was deleted.

Binary file removed threads/build/lib/kernel/debug.o
Binary file not shown.
5 changes: 0 additions & 5 deletions threads/build/lib/kernel/hash.d

This file was deleted.

Binary file removed threads/build/lib/kernel/hash.o
Binary file not shown.
Loading

0 comments on commit 2c75619

Please sign in to comment.