Skip to content
Snippets Groups Projects
Commit 3aabe594 authored by swsyp's avatar swsyp
Browse files

day1, day2 markdown 필기 업로드

parent 51b6c568
Branches main
No related tags found
No related merge requests found
...@@ -8,31 +8,130 @@ pupeeteer: ...@@ -8,31 +8,130 @@ pupeeteer:
### 실전코딩2 필기노트 ### 실전코딩2 필기노트
##### 강의자: 이환용 교수님 ##### 강의자: 이환용 교수님
### linux shell(bash) command ### linux shell(bash) command
- $? ; exit status (return value) of the last command - $? ; exit status (return value) of the last command
- $0 ; name of the script - $0 ; name of the script
- `$` 자체는 reference variable로 사용된다. (name="alice"; echo "hello $name" -> 출력: hello alice) - `$` 자체는 reference variable로 사용된다. (name="alice"; echo "hello $name" -> 출력: hello alice)
- ps ; list of processes running
- bash : linux shell에서 실행하는 프로그램
- cc `filename` ; compile the written c file and create a.out
- a.out 또는 ./a.out ; run compiled executable file
- a.out가 다른 색으로 표현되었던 이유는 permission과 관련 O
- ? ; previous one character
- tty ; terminal teller ; 장치 번호 출력
- w ; 터미널들의 working station state 출력
- redirection ; [file descriptor][redirection 방향] 그리고 [redirected file]을 입력
- Symbolic link로 연결해둔 stdin, stdout, stderr의 destination을 변경
- 예) a.out 0< `infile` >& `allfile`
- stdin ; fd=0
- stdout ; fd=1
- stderr ; fd=2
- fflush ; 순서 강제 지정 (fflush로 감싼 function이 완료될 때까지 CPU wait)
- buffer를 clear out 할 때도 사용 가능…? << 2번 예제
- buffer를 flush out
- grep `argument` ; find the location of the `argument`
### vi editor ### vi editor
- dd ; remove currently selected line - dd : remove currently selected line
- {n}yy ; yank(copy) n lines from the cursor - `k` yy : yank(copy) `k` lines from the cursor
- p ; paste yanked(copied) components - p : paste yanked(copied) components
</br><br>
### Day1 ### Day1
1. static == global by default (다른 파일로부터의 접근을 막음.) 1. static ; global by default (다른 파일로부터의 접근을 막음)</br><br>
2. 폰 노이만 format 2. 폰 노이만 (von Neumann) format
- 컴퓨터의 구성 4요소: HW system, SW system, User, Data - 컴퓨터의 구성 4요소: HW system, SW system, User, Data
- HW system의 구성 4(5)요소: CPU, Memory, Storage, I/O devices - HW system의 구성 4요소: CPU, Memory, Storage, I/O devices
- SW system은 system SW, application SW로 구성됨. - SW system은 system SW, application SW로 구성됨.
- system SW의 대표적인 예가 OS와 Compiler - system SW의 대표적인 예: OS, **Compiler (컴파일러도 소프트웨어다)**</br><br>
3. Terminal(단말기): 시스템의 끝에 위치한 기기들(사용자 디바이스, 서버 등) 통칭 3. Terminal(단말기): 시스템의 끝에 위치한 기기들(사용자 디바이스, 서버 등) 통칭
- shell (운영체제 라이브러리 - 운영체제 외 라이브러리 사이에 위치)도 터미널의 한 종류. - shell (운영체제 라이브러리 - 운영체제 외 라이브러리 사이에 위치)도 터미널의 한 종류.
- shell에서 ssh로 - ssh로 원격 접속을 통해 bash shell 터미널을 생성하면 **표준 입출력 장치 (STDIN, STDOUT, STDERR)** 생성</br><br>
4. Buffer Control
- control 옵션을 사용하지 않는 경우, buffer_size = 1
- Line buffer control (*EOF is also a line*)의 경우, line 별로 관리 (look for ‘\n’ or EOF)
- Block buffer control의 경우, buffer를 blocks으로 분리( =another buffers) and **do not flush** buffers before they are full</br><br>
5. 기타
- buffer로 메모리 크기보다 큰 값이 들어온다면 반환한다.
- **misra C**
- C언어 파일을 작성할 때 지켜야 하는 프로그래밍 규칙. 전체 C언어의 범주보다 더 작은 범주 내에서 사용 가능한 기능들에 대한 요구사항을 구체적으로 명시.
### Day2 ### Day2
- **Sort** -> numerical X, alphabetic ( =dictionary) order is default option
- man sort for more
- *EOF == ctrl+D*
- **파이프로 연결된 명령어는 “subshell”에서 실행됨**
- *ex) cmd1 | cmd2의 경우, “병렬”로 실행됨*
- OS에서 했던 process pipelining이랑 같음
- 단, MSB를 공유할지는 프로그래밍 원칙에 따라 다름
- But, kill 시킨 process는 catch하기 어려움 -> 보통 run 또는 wait state
- foreground/background 인지도 구별됨 (fg/bg 전환하는 명령어도 ‘kill’)
- linux manual : kill == ‘send a signal to a process’
(process 끝내기는 [9]SIGKILL signal로 정의되어 있음 => -l 참조)
- cmd2가 먼저 close 되는 경우?
- (1은 SIGPIPE signal을 받아서 종료될 수도, 유지될 수도 있음)
- 파이프도 &연산자로 r/w 묶어서 사용할 수 있는 거 기억하기
- pipe는 git에 안 올라감, named pipe는 mkfifo 명령어
- C code로 pipe 쓰기 : FILE *popen(*cmd, *type)
- type -> read, write
- WSL2나 Docker 쓸 때는 install man 필요함 > 근데 용량 큼 주의
- *그래서 그냥 git bash 설치하는 게 빠를지도*
- *WSL2은 Valgrind/Valyrie 페이지 참고해서 툴 설치해서 쓰면 좋을 듯*
</br><br>
**cmake 명령어: 빌드 결과물로 makefile 생성**
VS code -> based on ‘Electron’ SW framework
(Previously, Atom Shell -> why Atom expansions are easily attached to VS code)
*Node.js으로 개발 -> extension으로 GitHub manual 추가하는 것도 고려해볼만*
**Optimization의 전처리 단계 : Profiling이 필수적임(최적화 타겟을 분석)**
-> profiler가 감지한 최적화 대상이 혼재하면 최적화 효율이 떨어지는 거고, 그 반대면 비약적으로 효율 증대 가능
==> 결론적으로 compiler가 중요쓰
컴파일 단계도 2 phase로 구분 가능
- Phase 1: C preprocessing (compile # files -> check out ‘.i’ format files after cpp command. Compiled codes will be fetched at the bottom of the .i files)
- Phase 2: compile ‘user’ C codes
- Final Phase: after P1 and P2, combine every created c code and create an assembly file
*loading의 핵심은 disk file system으로부터 memory의 code부에 ‘실행(executable)’ 파일을 copy? 였나 아니면 patch하는 거였나….<<<*
*code generation procedure에서의 cpp의 의미는 C preprocessor*
**compiler normally assumes x86-64 environment, but cross compilers for different OS and CPU versions do exist**
**cpp command에 redirection을 사용할 수 있다는 것 == output이 stdout으로 출력됨**
**DEFINE 할 때는 진짜 긴 것만 -> cpp 단계에서부터 macro 지옥은 좀**
cc options -> -s ; create .s (assembly) file / -c ; create .o (binary) file
cc -o hello hello.c
== cc -o hello hello.i
== cc -o hello hello.s
== cc -o hello hello.o
//option별로 c preprocessing 단계가 어떻게 다른지 copilot한테 물어보기
manual에서 ‘determine’이라고 표기되는 지점은 파일을 직접 introspect해서 판단을 내린다는 의미 -> i.e., 파일명을 .c에서 .java로 변경해도 file cmd는 java가 아닌 c source code로 판별
명령어 strings ; binary 중에 읽을 수 있는 부분 표시
strip ; code 일부 잘라내기 (hack의 위험성을 방지할 때 사용,
덤으로 실행 파일 사이즈 축소)
nm ; list symbols from object files (nm 출력 결과물은 모두 ‘global’ 단위)
ldd ; dependency 경로 확인하기 (shared가 있는 경우만 출력해줌)
라이브러리 (i.e., printf) -> shared/dynamic lib를 사용하는지는 ‘file’하면 나옴
default ; dynamic{shared}
*lib version 안 맞는 경우에 static으로 붙여서 실행시키기 가능*
Compile Options
1. -W-all로 모든 레벨의 경고를 항상 확인
2. -m32/-m64 -> profiler 사용 단계에서 필요
Compile Multiple files
- Function -> very expensive, costly
- 간단한 함수는 macro (C++은 inline)로 정의해서 사용
- 연습 좀..
- (header file은 컴파일 필요 X, 파일들 작성한 후에 파라미터, 실행 파일명 순으로 입력)
### Day3 ### Day3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment