This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'linux-command/' from commit '3902ba06096a96f88be478d3bbc261380e6…
- Loading branch information
Showing
12 changed files
with
2,765 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Execute files | ||
mytop | ||
mylscpu | ||
myps | ||
|
||
# Temporary files | ||
.dependency | ||
*.sh | ||
*.txt | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
.SUFFIXES: .c .o | ||
.PHONY: dep all new clean | ||
|
||
# Compiler | ||
CC = gcc | ||
# Compile option | ||
# -c: Generate object file | ||
# -W, -Wall: Print warning about all ambigous grammer | ||
# -Wextra: Print warning out of -W, -Wall | ||
# -O2: Optimization | ||
# -g: Debugging, PLEASE DELETE AFTER PROJECT COMPLETE! | ||
CFLAGS = -c -W -Wall -Wextra -g $(INC) | ||
|
||
# Execute program file | ||
MYTOP = mytop | ||
MYPS = myps | ||
MYLSCPU = mylscpu | ||
# Source file | ||
COMMON_SRCS = common.c | ||
MYTOP_SRCS = mytop.c | ||
MYPS_SRCS = myps.c | ||
MYLSCPU_SRCS = mylscpu.c | ||
SRCS = $(COMMON_SRCS) $(MYTOP_SRCS) $(MYPS_SRCS) $(MYLSCPU_SRCS) | ||
# Object file | ||
COMMON_OBJS = $(COMMON_SRCS:.c=.o) | ||
MYTOP_OBJS = $(MYTOP_SRCS:.c=.o) | ||
MYPS_OBJS = $(MYPS_SRCS:.c=.o) | ||
MYLSCPU_OBJS = $(MYLSCPU_SRCS:.c=.o) | ||
OBJS = $(MYTOP_OBJS) $(MYLSCPU_OBJS) $(MYPS_OBJS) | ||
# Library file | ||
LIBS = -lncurses | ||
# Include path | ||
INC = | ||
|
||
# Execute file grneration | ||
# $@ = TARGET | ||
# $^ = DEPENDENCY | ||
# make all: Make all execute file | ||
all : $(OBJS) | ||
$(CC) -o $(MYTOP) $(MYTOP_OBJS) $(LIBS) | ||
$(CC) -o $(MYPS) $(MYPS_OBJS) $(LIBS) | ||
$(CC) -o $(MYLSCPU) $(MYLSCPU_OBJS) $(LIBS) | ||
$(MYTOP) : $(MYTOP_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
$(MYPS) : $(MYPS_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
$(MYLSCPU) : $(MYLSCPU_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
|
||
# Object file generation | ||
$(MYTOP_OBJS): | ||
$(CC) $(CFLAGS) $(MYTOP_SRCS) | ||
$(MYPS_OBJS): | ||
$(CC) $(CFLAGS) $(MYPS_SRCS) | ||
$(MYLSCPU_OBJS): | ||
$(CC) $(CFLAGS) $(MYLSCPU_SRCS) | ||
|
||
# make dep: Make dependency information file | ||
dep: | ||
$(CC) -M $(INC) $(SRCS) > .dependency | ||
|
||
# make new: Re-generation | ||
new: | ||
$(MAKE) clean | ||
$(MAKE) all | ||
|
||
# make clean: Remove all generated file | ||
clean: | ||
rm *.o $(MYTOP) $(MYPS) $(MYLSCPU) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Linux Command | ||
|
||
리눅스 명령어인 top, ps, lscpu 명령어 구현 | ||
|
||
## 0. Quick start | ||
|
||
``` bash | ||
$ git clone https://github.com/codejune/c-linux-command.git | ||
$ cd c-linux-command | ||
|
||
# 일괄 빌드 | ||
$ make | ||
|
||
# 개별 빌드 | ||
$ make mytop | ||
$ ./mytop | ||
``` | ||
|
||
## 1. Environment | ||
|
||
### Software | ||
|
||
- Ubuntu 20.04.3 LTS (x86_64) | ||
- Linux Kernel 5.11.22 | ||
|
||
### Hardware | ||
|
||
- VM Instance | ||
- 4 Core 8 Thread | ||
- 8 GB RAM | ||
- 60 GB Storage | ||
|
||
## 2. Requirement | ||
|
||
### 조건 | ||
|
||
- system() or exec() 계열 함수를 사용하여 해당 명령어를 호출 금지 | ||
- mytop, myps 명령어는 리눅스 top, ps 명령어와 최대한 유사한 결과를 출력하게 구현 | ||
- mylscpu 명령어의 경우 필수 구현 항목은 CPU Vendor ID, CPU 모델명, CPU 속도, 캐쉬 크기(L1i, L1d, L2 캐쉬) 이며 그 외의 항목은 추가 option으로 취급 | ||
|
||
### 출력 | ||
|
||
- mytop | ||
|
||
 | ||
|
||
- myps | ||
|
||
 | ||
|
||
- mylscpu | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.