일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- 스택
- N과M
- level3
- 그리디
- 재귀
- 운영체제
- 다익스트라
- MYSQL
- 백준
- 수학
- BFS
- dfs
- 가상메모리 관리
- level1
- programmers
- 브루트포스
- 가상메모리
- level2
- 파이썬
- 힙
- 프로그래머스
- 코딩테스트
- 딕셔너리
- DP
- 다이나믹 프로그래밍
- BOJ
- level0
- python
- 구현
- dict
- Today
- Total
목록CS/시스템프로그래밍 (13)
동캄의 코딩도장
System calls for fileIO Duplicating FD - dup(2) /dup2(2) #include int dup (int oldfd); int dup2 (int oldfd, int newfd); oldfd (old file descriptor) - 복사하려는 file descriptor newfd (new file descriptor) - 새로운 fd 지정 - dup()의 경우 할당 가능한 fd중 가장 작은 값 할당 Return: oldfd를 복사한 새로운 fd (-1: error) Manipulating FD - fcntl(2) #include #include int fnctl (int fd, int cmd, /* arg*/ ...); fd (file descriptor) - 대상 ..
파일 읽기/쓰기 (File read and write) Reading a fiel - read(2) ex) #include ssize_t read ( int fd, void *buf , size_t count); fd (file descriptor) - 읽으려는 파일의 file descriptor buf (buffer) - 읽은 내용을 저장할 buffer의 시작 주소 count - 읽을 byte의 수 Return: 실제로 읽은 byte의 수( 0: 파일 끝에 도달, -1: 에러) Writing to a file - write (2) #include ssize_t write (int fd, const void *buf, size_t count); fd (file descriptor) - 기록하려는 파일의 ..
Low-level vs High-level file IO Low-level File IO (System call) - System call을 이용해서 파일 입출력 수행 - FIle descriptor 사용 - Byte 단위로 디스크에 입출력 - 특수 파일에 대한 입출력 가능 High-level File IO (Buffered IO) - C Standard libary를 사용해서 파일 입출력 수행 - File pointer 사용 - 버퍼(block) 단위로 디스크에 입출력 Low-level File I/O에 대해 살펴볼 예정 file I/O = open/close , read/write, create/remove Openning files - open(2) ex) #include #include #incl..
File 보조 기억 장치에 저장된 연관된 정보들의 집합 - 보조 기억 장치 할당의 최소 단위 - Sequence of bytes Types of files in Unix/Linux - Regular file (일반 파일) Text or binary data file - Directory Unix/Linux에서는 directory도 하나의 파일 -special file (특수 파일) 파일 형태로 표현된 커널 내 객체 (자원에 대한 시스템 내부적 표현) 데이터 전송, 장치 접근 시 사용하는 파일 Basic commands for file ls(list) '-l' 상세 파일 정보 출력 '-a' 모든파일(숨겨진 파일 포함) 목록 출력 ( .으로 시작하는 파일) touch - 빈 파일 생성 or 파일의 time ..
Makefile - Compile 방법을 기술 하는 파일 (관련 파일 정보, compile 명령, 실행 파일명 등) - 여러 파일로 구성된 프로젝트 설정과 비슷한 개념 - 소스코드가 있는 폴더에 위치 Make - 주어진 Makefile에 따라 compile을 수행하고, 실행파일을 생성 - 최초 컴파일 이후에는, 변경이 있는 파일만 컴파일 함 Makefile이 없다면 - 각 파일 하나하나 complie하고, linking작업을 해주어야 함 - code 수정시에 실수 발생 가능 Makefile Rule - Rule block : - Implicit rules -> 자주 사용되는 규칙을 자동으로 처리 해줌 (단, Target에 대한 Dependency까지는 명시 할 것) Makefile variables 예제..