Discrete Mathematics

Size: px
Start display at page:

Download "Discrete Mathematics"

Transcription

1 컴퓨터특강 () [Ch. 4] 2005 년봄학기 문양세컴퓨터과학과강원대학교자연과학대학

2 강의목표및내용 강의목표 파일의상태및구조를이해한다. 파일시스템구현을이해한다. 디렉토리구조및구현을이해한다. 강의내용 파일상태 파일접근허가권 파일시스템구현 링크 (link) 디렉토리 Page 2

3 stat() 파일상태확인 #include <sys/types.h> #include <sys/stat.h> int stat (const char *pathname, struct stat *buf ); int fstat (int filedes, struct stat *buf ); int lstat (const char *pathname, struct stat *buf ); 역할 : 주어진파일에대한정보를 stat 구조체에얻어온다. buf: stat 구조체에대한포인터 ( 정보를가져올장소 ) lstat() 은 Symbolic Link가가리키는파일이아닌 Symbolic Link 자체에대한정보를얻는다. 리턴값 : 성공하면 0, 실패하면 -1 Page 3

4 stat 구조체 (1/2) <sys/stat.h> 에정의 struct stat { mode_t st_mode; /* file type & mode (permissions) */ ino_t st_ino; /* i-node number (serial number) */ dev_t st_dev; /* device number (filesystem) */ dev_t st_rdev; /* device number for special files */ nlink_t st_nlink; /* number of links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ off_t st_size; /* size in bytes, for regular files */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last file status change */ long st_blksize;/* best I/O block size */ long st_blocks; /* number of 512-byte blocks allocated */ }; Page 4

5 stat 구조체 (2/2) st_atime: 마지막으로파일의데이터를읽은시각 st_mtime: 마지막으로파일의데이터를수정한시각 st_ctime: 파일의내용이아니고이름 / 권한같은상태를변경한시각 st_blksize: 가장효율적인 I/O 블럭크기 ( 예 : 8192 bytes) st_blocks: 파일이차지하고있는공간의크기 (512 byte 의블록수 ) Page 5

6 파일타입 (1/3) 보통파일 (Regular File) 데이터를포함하고있는텍스트또는이진파일 디렉토리파일 (Directory File) 파일의이름들과파일정보에대한포인터들을포함 문자특수파일 (Character Special File) 시스템에장착된어떠장치를가리키는파일 문자단위로데이터를전송하는장치 (c ) 블록특수파일 (Block Special File) 시스템에장착된어떤장치를가리키는파일 블럭단위로데이터를전송하는장치 (b ) Page 6

7 파일타입 (2/3) 특수파일예제 Page 7

8 파일타입 (3/3) FIFO 프로세스간통신에사용되는파일 (IPC Programming에서사용됨 ) Named Pipe라고도부름 소켓 (socket) 네트워크를통한프로세스간통신에사용되는파일 Network Programming에서사용하는보편적인방법 심볼릭링크 (Symbolic link) 다른파일을가리키는포인터역할을하는파일 (Windows 의 바로가기 에해당 ) Page 8

9 파일타입검사 (1/2) 파일타입을검사하는매크로함수 stat.h 파일 (/usr/include/sys/stat.h) 에정의되어있음 S_ISREG() S_ISDIR() S_ISCHR() S_ISBLK() : 정규파일 : 디렉토리파일 : 문자특수파일 : 블록특수파일 st_mode type special permission 4 bits 3 bits 9 bits S_ISFIFO() : pipe 또는 FIFO S_ISLNK() : 심볼릭링크 S_ISSOCK() : 소켓 해당종류의파일이면 1, 아니면 0 을리턴 stat 구조체의 st_mode 값을검사함 Page 9

10 파일타입검사 (2/2) 파일타입상수 stat.h 파일 (/usr/include/sys/stat.h) 에정의되어있음 S_IFREG S_IFDIR S_IFCHR S_IFBLK : 정규파일 : 디렉토리파일 : 문자특수파일 : 블록특수파일 S_IFFIFO : pipe 또는 FIFO S_IFLNK : 심볼릭링크 S_IFSOCK : 소켓 S_ISxxx() 매크로함수는 S_IFxxx 상수값의설정여부를판단 Page 10

11 예제 : stat.c (1/2) #include <sys/types.h> /* stat.c */ #include <sys/stat.h> int main(int argc, char *argv[]) { int i; struct stat buf; char *ptr; for (i = 1; i < argc; i++) { printf("%s: ", argv[i]); if (lstat(argv[i], &buf) < 0) { perror("lstat()"); continue; } if (S_ISREG(buf.st_mode)) ptr = "regular"; else if (S_ISDIR(buf.st_mode)) ptr = "directory"; else if (S_ISCHR(buf.st_mode)) ptr = "character special"; else if (S_ISBLK(buf.st_mode)) ptr = "block special"; else if (S_ISFIFO(buf.st_mode)) ptr = "fifo"; else if (S_ISLNK(buf.st_mode)) ptr = "symbolic link"; else if (S_ISSOCK(buf.st_mode)) ptr = "socket"; else ptr = "** unknown mode **"; printf("%s\n", ptr); } exit(0); } Page 11

12 예제 : stat.c (2/2) 실행결과 $ a.out /etc /dev/ttya /bin a.out /etc: directory /dev/ttya: symbolic link /bin: symbolic link a.out: regular Symbolic Link 에대한정보도얻기위해서 stat() 대신 lstat() 을사용 Page 12

13 파일허가권 (File Permissions) File access permission bits (stat 구조체의 st_mode 값 ) st_mode type special permission 4 bits 3 bits 9 bits st_mode mask Meaning Octal Code S_IRUSR user-read 0400 S_IWUSR user-write 0200 S_IXUSR S_IRGRP S_IWGRP S_IXGRP S_IROTH S_IWOTH S_IXOTH user-execute group-read group-write group-execute other-read other-write other-execute Page 13

14 관련명령어 UNIX 명령어 chmod File Access Permission 설정 stat 구조체의 st_mode 값을변경 UNIX 명령어 chown File 소유 User ID 설정 stat 구조체의 st_uid 값을변경 UNIX 명령어 chgrp File 소유 Group ID 설정 stat 구조체의 st_gid Page 14

15 허가권 (Permissions) (1/2) Read 권한이있어야 O_RDONLY, O_RDWR 를사용하여파일을열수있다. Write 권한이있어야 O_WRONLY, O_RDWR, O_TRUNC 를사용하여파일을열수있다. 디렉토리에 write 권한과 execute 권한이있어야 해당디렉토리에파일을생성할수있고, 그디렉토리의파일을삭제할수있다 Page 15

16 허가권 (Permissions) (2/2) 파일이포함된모든상위디렉토리에대해 execute 권한이있어야그파일을열수있다. 디렉토리에대한 read 권한이있어야디렉토리안에들어있는파일이름목록을읽을수있다. 디렉토리에대한 write 권한이있어야디렉토리에파일을생성삭제할수있다. 디렉토리에대한 execute 권한이있어야그디렉토리나그하위디렉토리에있는파일을열수있다. Page 16

17 Effective User ID Real User ID 와 Real Group ID 실제사용자 ID와그사용자가속한그룹 ID 로그인한사용자 ID 일반적으로, Shell 상에서작업을수행할때의 User 및 Group ID로이해할수있음 Effective User ID 와 Effective Group ID 프로세스의속성 대부분의경우 Real User ID 와 Real Group ID 가사용되나, 다음에설명하는 S_ISUID와 S_ISGID 비트가 Set된경우에는다르게동작함 일반적으로, 프로세스가수행될때의 User ID 및 Group ID로이해할수있음 Page 17

18 S_ISUID 와 S_ISGID (1/2) stat 구조체의 st_mode 의비트로표현됨 S_ISUID : set-user-id S_ISGID : set-group-id st_mode type special permission 4 bits 3 bits 9 bits st_mode 의 S_ISUID 비트가설정된실행파일을실행한경우 그실행파일이실행된프로세스의 Effective User ID는 Real User ID가아니고, 그실행파일소유자의 User ID가된다. st_mode 의 S_ISGID 비트가설정된실행파일을실행한경우 그실행파일이실행된프로세스의 Effective Group ID는 Real Group ID가아니고, 그실행파일소유자의 group ID가된다. Page 18

19 S_ISUID 와 S_ISGID (2/2) S_ISUID, S_ISGID 모두가설정된실행파일을실행하는경우 Real User ID, Real Group ID 의권한이아니고, 그파일소유 User ID, Group ID 의권한으로실행됨 예제 ) $ ls -al /bin/passwd -r-sr-sr-x 1 root sys Jul /bin/passwd* Page 19

20 access() #include <unistd.h> int access (const char *pathname, int mode ); Real User ID 와 Real Group ID 로파일의허가권검사 리턴값 : 성공하면 0, 실패하면 -1 mode 값 mode R_OK W_OK X_OK F_OK Description test for read permission test for write permission test for execute permission test for existence of tile Page 20

21 예제 : access() #include <sys/types.h> // access.c #include <fcntl.h> #include <unistd.h> int main(int argc, char *argv[]) { if (argc!= 2) { printf("usage: a.out <pathname>\n"); exit(-1); } if (access(argv[1], R_OK) < 0) perror("r_ok"); else printf("read access OK\n"); if (open(argv[1], O_RDONLY) < 0) perror("o_rdonly"); else printf("open for reading OK\n"); } return 0; Page 21

22 chmod(), fchmod() #include <sys/stat.h> #include <sys/types.h> int chmod (const char *pathname, mode_t mode ); int fchmod (int filedes, mode_t mode ); 파일에대해 Access Permission 을변경한다 stat 구조체의 st_mode 변경 리턴값 : 성공하면 0, 실패하면 -1 mode : bitwise OR S_ISUID, S_ISGID, S_ISVTX S_IRUSR, S_IWUSR, S_IXUSR S_IRGRP, S_IWGRP, S_IXGRP S_IROTH, S_IWOTH, S_IXOTH Page 22

23 예제 : chmod() (1/2) #include <sys/types.h> // nchmod.c #include <sys/stat.h> int main() { struct stat statbuf; /* turn on both set-group-id and group-execute */ if (stat("foo", &statbuf) < 0) perror("stat(foo)"); if (chmod("foo", (statbuf.st_mode S_IXGRP S_ISGID)) < 0) perror("chmod(foo)"); /* set absolute mode to "rw-r--r--" */ if (chmod("bar", S_IRUSR S_IWUSR S_IRGRP S_IROTH) < 0) perror("chmod(bar)"); } return 0; Page 23

24 예제 : chmod() (2/2) 실행결과 Page 24

25 chown() #include <sys/types.h> #include <unistd.h> int chown (const char *pathname, uid_t owner, gid_t group ); int fchown (int filedes, uid_t owner, gid_t group ); int lchown (const char *pathname, uid_t owner, gid_t group ); 파일의 User ID 와 Group ID 를변경한다. stat 구조체의 st_uid, st_gid 변경 리턴값 : 성공하면 0, 실패하면 -1 lchown() 은심볼릭링크자체를변경한다. UNIX 종류및버전에따라차이가있을수있다. BSD 기반시스템에서는 super-user 만변환가능 System V 계열시스템은일반사용자도변경가능 Page 25

26 truncate(), ftruncate() #include <sys/types.h> #include <unistd.h> int truncate (const char *pathname, off_t length ); int ftruncate (int filedes, off_t length ); 파일의크기를주어진 length 로줄인다. 리턴값 : 성공하면 0, 실패하면 -1 Page 26

27 강의목표및내용 강의목표 파일의상태및구조를이해한다. 파일시스템구현을이해한다. 디렉토리구조및구현을이해한다. 강의내용 파일상태 파일접근허가권 파일시스템구현 링크 (link) 디렉토리 Page 27

28 Block I/O I/O is always done in terms of blocks. Sequence of a read() system call read() system call trap n bytes I/O request the device driver (software in kernel) the disk controller (hardware) one block at a time interrupt Page 28

29 Inode (Index Node) 한파일은하나의 i-node를갖는다. 파일에대한정보를가지고있다. file size file permissions the owner and group ids the last modification and last access times if it's a regular or directory, the location of data blocks if it's a special file, device numbers if it's a symbolic link, the value of the symbolic link stat 구조체의필드는 i-node 에서읽어온다. Page 29

30 The Block Map (1/2) Direct block pointers 10 direct block pointers Indirect block pointer an indirect block to address 1024 blocks Double indirect block pointer an double indirect block to contain 1024 indirect block pointers How many blocks can be addressed? You may meet this question in the final exam. Page 30

31 The Block Map (2/2) Inode Disk blocks Direct block pointers... to blocks Indirect pointers Double indirect pointers To blocks (1024 blocks) Locates up to 1000 indirects To blocks Page 31

32 File System Layout (1/3) Boot Block Boot code that is used when UNIX is first activated. Super Block (information about the entire file system) the total number of blocks in the file system the number of inodes in the inode free list a bit map of free blocks the size of block in bytes the number of free blocks the number of used blocks Page 32

33 File System Layout (2/3) i-list ( 다음페이지참조 ) all the inodes associated with the files on the disk each block in the inode list can hold about 40 inodes User Blocks for storing file blocks Bad Blocks Several block that cannot be used Page 33

34 File System Layout (3/3) Boot block Super block Inodes Inodes User block User block... User block i-list User blocks Page 34

35 강의목표및내용 강의목표 파일의상태및구조를이해한다. 파일시스템구현을이해한다. 디렉토리구조및구현을이해한다. 강의내용 파일상태 파일접근허가권 파일시스템구현 링크 (link) 디렉토리 Page 35

36 unlink() #include <unistd.h> int unlink (const char *pathname); 파일을삭제하는역할을수행함 ( 엄밀히말해서, 파일의 link count를감소시킴 ) stat 구조체의 st_mode 변경 리턴값 : 성공하면 0, 실패하면 -1 파일이삭제될경우, inode와 data block이삭제 (free) 된다. Page 36

37 예제 : unlink() (1/2) #include <sys/types.h> // unlink.c #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main() { int fd, len; char buf[20]; fd = open("tempfile", O_RDWR O_CREAT O_TRUNC, 0666); if (fd == -1) perror("open1"); close(fd); system("ls -l"); unlink("tempfile"); system("ls -l"); } return 0; Page 37

38 예제 : unlink() (2/2) 실행결과 Page 38

39 symlink() - Symbolic Link Symbolic Link 는파일에대한간접적인포인터임 실제파일에대한 경로 를저장하고있는파일임 #include <unistd.h> int symlink (const char *actualpath, const char *sympath ); Symbolic Link 를만든다. Symbolic Link File의내용은actualpath에해당함 Symbolic Link File의크기는actualpath 문자열의길이 ( 즉, 저장되는내용이문자열 ) 리턴값 : 성공하면 0, 실패하면 -1 파라미터설명 actualpath: 실제파일 sympath: 만들 Symbolic Link의이름 Page 39

40 파일관련시간 stat 구조체의 st_atime 파일의데이터가마지막으로읽혔던 (read 되었던 ) 시간 즉, 마지막으로 read() 가호출된시간 stat 구조체의 st_mtime 파일의데이터가마지막으로변경 (write) 된시간 즉, 마지막으로 write() 가호출된시간 stat 구조체의 st_ctime 파일의 stat 구조체의내용이마지막으로변경된시간 chmod(), chown() 등이호출된시간 Page 40

41 utime() #include <sys/types.h> #include <utime.h> int utime (const char *pathname, const struct utimbuf *times ); 파일의최종접근시간과최종변경시간을조정한다. times가 NULL 이면, 현재시간으로설정된다. 리턴값 : 성공하면 0, 실패하면 -1 UNIX 명령어 touch 참고 struct utimbuf { time_t actime; /* access time */ time_t modtime; /* modification time */ } 각필드는 :00 부터현재까지의경과시간을초로환산한값 Page 41

42 디렉토리 (Directory) 디렉토리파일 일종의파일이므로 open, read, close 함수등을사용할수있다. 디렉토리파일사용에편리한새로운함수들도제공된다. 디렉토리파일의내용은구조체 dirent 의배열형태로저장됨 file name: 파일이름, 하위디렉토리이름,.,.. i-node number #include <dirent.h> struct dirent { ino_t d_ino; /* i-node number */ char d_name[name_max + 1]; /* filename */ } Page 42

43 디렉토리접근 (opendir(), readdir()) #include <sys/types.h> #include <dirent.h> DIR *opendir (const char *pathname); struct dirent *readdir(dir *dp); opendir() 로디렉토리파일을열고, readdir() 로디렉토리파일의내용을읽는다. 읽을때마다디렉토리파일의 current file offset은읽은구조체 dirent의크기만큼증가한다. 디렉토리의항목읽기위해서는해당디렉토리에대한읽기권한이있어야한다. 그러나, 쓰기권한이있어도 write 함수로직접쓸수는없으며, mkdir(), rmdir() 함수를사용해야한다. 리턴값 : 성공하면구조체주소, 실패하면 NULL Page 43

44 rewinddir(), closedir() #include <sys/types.h> #include <dirent.h> void rewinddir (DIR *dp); int closedir (DIR *dp); rewinddir() 디렉토리파일의 current file offset 을처음으로옮긴다. ( 첫번째엔트리로옮긴다.) closedir() 디렉토리파일을닫는다. 리턴값 : 성공하면 0, 실패하면 -1 Page 44

45 mkdir() #include <sys/types.h> #include <sys/stat.h> int mkdir (const char *pathname, mode_t mode ); 새로운디렉토리를만든다. 리턴값 : 성공하면 0, 실패하면 -1 성공하면,. 와.. 파일은자동적으로만들어진다.. 은현재디렉토리파일의 i-node를,.. 은부모디렉토리파일의 i-node를각각가리킨다. Page 45

46 rmdir() #include <unistd.h> int rmdir (const char *pathname ); 비어있는디렉토리를삭제한다. 리턴값 : 성공하면 0, 실패하면 -1 Page 46

47 예제 : listfiles.c (1/5) #include <sys/types.h> // listfiles.c #include <sys/mkdev.h> #include <sys/stat.h> #include <dirent.h> #include <stdio.h> /* typeoffile - return the letter indicating the file type. */ char typeoffile(mode_t mode) { switch (mode & S_IFMT) { case S_IFREG: return('-'); case S_IFDIR: return('d'); case S_IFCHR: return('c'); case S_IFBLK: return('b'); case S_IFLNK: return('l'); case S_IFIFO: return('p'); case S_IFSOCK: return('s'); } return('?'); } Page 47

48 예제 : listfiles.c (2/5) /* permoffile - return the file permissions in an "ls"-like string. */ char* permoffile(mode_t mode) { int i; char *p; static char perms[10]; p = perms; strcpy(perms, " "); for (i=0; i < 3; i++) { if (mode & (S_IREAD >> i*3)) *p = 'r'; p++; if (mode & (S_IWRITE >> i*3)) *p = 'w'; p++; if (mode & (S_IEXEC >> i*3)) *p = 'x'; p++; } if ((mode & S_ISUID)!= 0) perms[2] = 's'; if ((mode & S_ISGID)!= 0) perms[5] = 's'; } return(perms); Page 48

49 예제 : listfiles.c (3/5) /* outputstatinfo - print out the contents of the stat structure. */ void outputstatinfo(char *pathname, char *filename, struct stat *st) { int n; char slink[bufsiz+1]; printf("%5d ", st->st_blocks); printf("%c%s ", typeoffile(st->st_mode), permoffile(st->st_mode)); printf("%3d ", st->st_nlink); printf("%5d/%-5d ", st->st_uid, st->st_gid); if (((st->st_mode & S_IFMT)!=S_IFCHR) && ((st->st_mode & S_IFMT)!=S_IFBLK)) printf("%9d ", st->st_size); else printf("%4d,%4d ", major(st->st_rdev), minor(st->st_rdev)); } printf("%.12s ", ctime(&st->st_mtime) + 4); printf("%s", filename); if ((st->st_mode & S_IFMT) == S_IFLNK) { if ((n = readlink(pathname, slink, sizeof(slink))) < 0) printf(" ->???"); else printf(" -> %.*s", n, slink); } Page 49

50 예제 : listfiles.c (4/5) int main(int argc, char **argv) { DIR *dp; char *dirname; struct stat st; struct dirent *d; char filename[bufsiz+1]; /* For each directory on the command line... */ while (--argc) { dirname = *++argv; if ((dp = opendir(dirname)) == NULL) /* Open the directory */ perror(dirname); printf("%s:\n", dirname); while ((d = readdir(dp))!= NULL) { /* For each file in the directory... */ /* Create the full file name. */ sprintf(filename, "%s/%s", dirname, d->d_name); if (lstat(filename, &st) < 0) /* Find out about it. */ perror(filename); outputstatinfo(filename, d->d_name, &st); /* Print out the info. */ putchar('\n'); } putchar('\n'); closedir(dp); } return 0; } Page 50

51 예제 : listfiles.c (5/5) 실행결과 Page 51

52 chdir(), fchdir() #include <unistd.h> int chdir (const char *pathname); int fchdir (int filedes); 현재작업디렉토리를변경한다. ($ cd) 반환값 : 성공하면 0, 실패하면 -1 현재작업디렉토리는프로세스의속성 ( 프로세스의 working directory가변하는것임 ) Page 52

53 getcwd() #include <unistd.h> char *getcwd (char *buf, size_t size ); 현재작업디렉토리의경로명을얻는다. ($ pwd) 반환값 : 성공하면 buf 의주소, 실패하면 NULL Page 53

54 예제 : chdir(), getcwd() (1/2) #include <unistd.h> // ncd.c #include <stdio.h> #define PATH_MAX 1024 int main(int argc, char **argv) { char path[path_max+1]; if (argc == 1) exit(-1); if (argc == 2) { if(getcwd(path, PATH_MAX) == NULL) perror("error getcwd"); else printf("current working directory changed to %s \n", path); } if(chdir(argv[1]) < 0) perror("error chdir"); else { if(getcwd(path, PATH_MAX) == NULL) perror("error getcwd"); else printf("current working directory changed to %s \n", path); } } else perror("too many arguments"); Page 54

55 예제 : chdir(), getcwd() (2/2) 실행결과 Page 55

56 sync(), fsync() #include <unistd.h> void sync(); int fsync(int filedes); 버퍼에있는내용을디스크에쓰도록한다. sync() 는시스템데몬프로세스에의해서 30초마다호출된다. fsync() 는지정된파일에대해서만 I/O 작업을수행하도록한다. 참고 ) O_SYNC 플래그 ( 모든 write() 를 sync mode 로처리함 ) Page 56

57 Homework #9 파일의 Permission 정보를다음과같이출력하는 myfinfo 를작성하여메일로제출한다. (Wide Card 문자는처리할필요없음 ) $ myfinfo somefile Owner Read = YES ( 혹은 NO) Owner Write = YES ( 혹은 NO) Owner Execute = YES ( 혹은 NO) Group Read = YES ( 혹은 NO) Group Write = YES ( 혹은 NO) Group Execute = YES ( 혹은 NO) Other Read = YES ( 혹은 NO) Other Write = YES ( 혹은 NO) Other Execute = YES ( 혹은 NO) Due Date: 6/1( 수 ) Page 57

Microsoft PowerPoint APUE(Files and Directories).ppt

Microsoft PowerPoint APUE(Files and Directories).ppt 컴퓨터특강 () [Ch. 4] 2006 년봄학기 문양세강원대학교컴퓨터과학과 강의목표및내용 강의목표 파일의상태및구조를이해한다. 파일시스템구현을이해한다. 디렉토리구조및구현을이해한다. 강의내용 파일상태 파일접근허가권 파일시스템구현 링크 (link) 디렉토리 Page 2 1 stat() 파일상태확인 #include #include

More information

Microsoft PowerPoint - chap3 [호환 모드]

Microsoft PowerPoint - chap3 [호환 모드] 제 3 장파일과디렉토리 숙대창병모 1 목표 파일시스템구현을이해한다. 파일의상태및구조를이해한다. 디렉토리구조및구현을이해한다. 숙대창병모 2 내용 1. 파일시스템구현 2. 파일상태 3. 파일접근허가권 4. 링크 5. 디렉토리 숙대창병모 3 3.1 파일시스템구현 숙대창병모 4 Inode (Index node) 한파일은하나의 i-node 를갖는다. 파일에대한모든정보를가지고있음

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 5 장파일시스템 상지대학교컴퓨터공학과고광만 kkman@sangji.ac.kr http://compiler.sangji.ac.kr 2018 5.1 파일시스템구현 파일시스템구조 0 1 2 3 200 201 부트블록슈퍼블록 i-노드 1..40 i-노드 41..80... 데이터블록데이터블록... i- 리스트 데이터블록 데이터블록 3 파일시스템구조 부트블록 (Boot

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 File System Jo, Heeseung 유닉스파일의특징 [1] 파일 유닉스에서파일은데이터저장, 장치구동, 프로세스간통신등에사용 일반파일, 디렉토리, 특수파일 일반파일 텍스트파일, 실행파일, 라이브러리, 이미지등유닉스에서사용하는대부분의파일 디렉토리 디렉토리도파일로취급 디렉토리에속한파일의목록과 inode 를가진파일 특수파일 - 장치파일 장치를파일로표현 예

More information

<4D F736F F F696E74202D FC6C4C0CFB0FA20B5F0B7BAC5E4B8AE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FC6C4C0CFB0FA20B5F0B7BAC5E4B8AE205BC8A3C8AF20B8F0B5E55D> 학습목표 유닉스파일의특징을이해한다. 파일에관한정보를검색하는함수를사용할수있다. 하드링크와심볼릭링크파일을이해하고관련함수를사용할수있다. 파일사용권한을검색하고조정하는함수를사용할수있다. 디렉토리의특징을이해한다. 디렉토리의내용을검색하는함수를사용할수있다. 디렉토리를생성하고삭제하는함수를사용할수있다. 파일과디렉토리 IT CookBook, 유닉스시스템프로그래밍 2/45 목차

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

Microsoft PowerPoint - 09_FileSystem

Microsoft PowerPoint - 09_FileSystem Linux 파일시스템프로그래밍 File System Programming - 파일시스템내부구조 - File Descriptor - File 기본작업시스템호출 - File 정보관리시스템호출 - Directory 관리시스템호출 이제부터는 시스템사용에만머물지않는다. 내부로들어가서건드려보고나만의시스템을만들자. 시스템호출 ( 또는표준 API) 을이용하여운영체제기능을프로그램에서사용

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 05 make 광운대학교로봇 SW 교육원 최상훈 학습목표 2 Makefile 을작성핛수있다. make 3 make 프로젝트관리유틸리티 컴파일시갂단축 파일의종속구조를빠르게파악핛수있음 기술파일 (Makefile) 에기술된대로컴파일명령또는셸 (shell) 명령을순차적으로수행 make 를사용하지않을경우 $ gcc c main.c $ gcc c test_a.c

More information

10.

10. 10. 10.1 10.2 Library Routine: void perror (char* str) perror( ) str Error 0 10.3 10.3 int fd; /* */ fd = open (filename, ) /*, */ if (fd = = -1) { /* */ } fcnt1 (fd, ); /* */ read (fd, ); /* */ write

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

Microsoft PowerPoint APUE(File InO).pptx

Microsoft PowerPoint APUE(File InO).pptx Linux/UNIX Programming 문양세강원대학교 IT대학컴퓨터과학전공 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 What is a File? A file is a contiguous

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 4 장파일 컴퓨터과학과박환수 1 2 4.1 시스템호출 컴퓨터시스템구조 유닉스커널 (kernel) 하드웨어를운영관리하여다음과같은서비스를제공 파일관리 (File management) 프로세스관리 (Process management) 메모리관리 (Memory management) 통신관리 (Communication management) 주변장치관리 (Device

More information

Microsoft PowerPoint - ch09_파이프 [호환 모드]

Microsoft PowerPoint - ch09_파이프 [호환 모드] 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 파이프 IT CookBook, 유닉스시스템프로그래밍 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 파이프 IT CookBook, 유닉스시스템프로그래밍 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 3/20 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

Microsoft PowerPoint APUE(File InO).ppt

Microsoft PowerPoint APUE(File InO).ppt 컴퓨터특강 () [Ch. 3] 2006 년봄학기 문양세강원대학교컴퓨터과학과 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 1 What is a File? A file is a contiguous

More information

제12장 파일 입출력

제12장 파일 입출력 제 4 장파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 시스템호출 (system call) 파일 (file) 임의접근 (random access) 주요학습내용 2 4.1 절 커널의역할 (kernel) 커널 (kernel) 은운영체제의핵심부분으로서, 하드웨어를운영관리하는여러가지서비스를제공함 파일관리 (File management) 디스크 프로세스관리

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

Microsoft PowerPoint APUE(File InO)

Microsoft PowerPoint APUE(File InO) Linux/UNIX Programming 문양세강원대학교 IT특성화대학컴퓨터과학전공 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 What is a File? A file is a contiguous

More information

Unix 의 역사 Bell Lab의 Ken Tompson이 PDP-7 위에서 개발 (1969년) Dennis Ritchie가 참가하여 대부분을 C언어로 작성 Sixth Edition 개발 (1976년) 다른 기관이 사용할 수 있도록 배포한 최초의 버전 이후에 UNIX는

Unix 의 역사 Bell Lab의 Ken Tompson이 PDP-7 위에서 개발 (1969년) Dennis Ritchie가 참가하여 대부분을 C언어로 작성 Sixth Edition 개발 (1976년) 다른 기관이 사용할 수 있도록 배포한 최초의 버전 이후에 UNIX는 고급 시스템 프로그래밍 (소프트웨어 개발 트랙) 제1장 소개 2004. 08. 22 1 Unix 의 역사 Bell Lab의 Ken Tompson이 PDP-7 위에서 개발 (1969년) Dennis Ritchie가 참가하여 대부분을 C언어로 작성 Sixth Edition 개발 (1976년) 다른 기관이 사용할 수 있도록 배포한 최초의 버전 이후에 UNIX는 크게

More information

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력 학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다고가정하자. / /bin/ /home/ /home/taesoo/ /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자가터미널에서다음 ls 명령입력시화면출력을예측하시오. $ cd /usr $ ls..? $ ls.? 2. 다음그림은어떤프로세스가다음코드를수행했다는가정에서도시되었다.

More information

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D> 학습목표 통신프로그램이무엇인지이해한다. 을이용한 IPC 기법을이해한다. 함수를사용해프로그램을작성할수있다. IT CookBook, 유닉스시스템프로그래밍 2/20 목차 의개념 함수 해제함수 의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 의개념 파일을프로세스의메모리에매핑 프로세스에전달할데이터를저장한파일을직접프로세스의가상주소공간으로매핑 read, write

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 메모리매핑 IT CookBook, 유닉스시스템프로그래밍 학습목표 통신프로그램이무엇인지이해한다. 메모리매핑을이용한 IPC 기법을이해한다. 메모리매핑함수를사용해프로그램을작성할수있다. 2/20 목차 메모리매핑의개념 메모리매핑함수 메모리매핑해제함수 메모리매핑의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 3/20 메모리매핑의개념 메모리매핑 파일을프로세스의메모리에매핑

More information

/chroot/lib/ /chroot/etc/

/chroot/lib/ /chroot/etc/ 구축 환경 VirtualBox - Fedora 15 (kernel : 2.6.40.4-5.fc15.i686.PAE) 작동 원리 chroot유저 ssh 접속 -> 접속유저의 홈디렉토리 밑.ssh의 rc 파일 실행 -> daemonstart실행 -> daemon 작동 -> 접속 유저만의 Jail 디렉토리 생성 -> 접속 유저의.bashrc 의 chroot 명령어

More information

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수있다. 학습내용 1 : 현재디렉토리확인 1. 홈디렉토리 - 로그인을한후, 사용자가기본으로놓이게되는디렉토리위치를홈디렉토리 (home directory)

More information

Microsoft PowerPoint - chap2

Microsoft PowerPoint - chap2 제 2 장. 파일입출력 (File I/O) 숙대창병모 1 목표 파일의구조및특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 파일현재위치변경 기타파일제어 숙대창병모 2 2.1 파일구조 숙대창병모 3 What is a file? a file is a contiguous sequence of bytes no format imposed by the operating

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED Controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-SEGMENT DEVICE CONTROL - DEVICE DRIVER Jo, Heeseung 디바이스드라이버구현 : 7-SEGMENT HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 디바이스드라이버구현 : 7-SEGMENT 6-Digit 7-Segment LED

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

More information

ABC 11장

ABC 11장 12 장고급응용 0 수행중인프로그램 프로세스 모든프로세스는유일한프로세스식별번호 (PID) 를가짐 유닉스에서는 ps 명령을사용하여프로세스목록을볼수있음 12-1 프로세스 $ ps -aux USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND blufox 17725 34.0 1.6 146 105 i2 R 15:13 0:00

More information

61 62 63 64 234 235 p r i n t f ( % 5 d :, i+1); g e t s ( s t u d e n t _ n a m e [ i ] ) ; if (student_name[i][0] == \ 0 ) i = MAX; p r i n t f (\ n :\ n ); 6 1 for (i = 0; student_name[i][0]!= \ 0&&

More information

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2 제 17 장동적메모리와연결리스트 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

Microsoft Word - Network Programming_NewVersion_01_.docx

Microsoft Word - Network Programming_NewVersion_01_.docx 10. Unix Domain Socket 105/113 10. Unix Domain Socket 본절에서는 Unix Domain Socket(UDS) 에대한개념과이에대한실습을수행하고, 이와동시에비신뢰적인통신시스템의문제점에대해서분석하도록한다. 이번실습의목표는다음과같다. 1. Unix Domain Socket의사용법을익히고, IPC에대해서실습 2. TCP/IP의응용계층과전달계층의동작을구현및실습

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

OPCTalk for Hitachi Ethernet 1 2. Path. DCOMwindow NT/2000 network server. Winsock update win95. . . 3 Excel CSV. Update Background Thread Client Command Queue Size Client Dynamic Scan Block Block

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

Microsoft PowerPoint - Lecture 4-1 Linux File Environment.ppt [호환 모드]

Microsoft PowerPoint - Lecture 4-1 Linux File Environment.ppt [호환 모드] Liux Programmig Sprig 2008 File Hadlig Importat cotets Liux 에서 C 컴파일방법 File 처리프로그래밍 Liux 환경접근프로그래밍 Kogju Natioal Uiversity Liux System Programmig 2/29 Basic compilig method Liux C Compiler : gcc, cc 기본

More information

Microsoft PowerPoint - chap12 [호환 모드]

Microsoft PowerPoint - chap12 [호환 모드] 제 12 장고급입출력 Nov 2007 숙대창병모 1 Contents 1. Nonblocking I/O 2. Record Locking 3. Memory Mapped I/O Nov 2007 숙대창병모 2 12.1 Nonblocking I/O Nov 2007 숙대창병모 3 Nonblocking I/O Blocking I/O I/O 작업완료를기다리며영원히리턴안할수있다

More information

Microsoft PowerPoint - 13 ¼ÒÄÏÀ» ÀÌ¿ëÇÑ Åë½Å 2.ppt

Microsoft PowerPoint - 13 ¼ÒÄÏÀ» ÀÌ¿ëÇÑ Åë½Å 2.ppt 13 장소켓을이용한통신 (2) 소켓을이용한통신 (2) 함수 - recvfrom - sendto - uname - gethostname - gethostbyname - gethostbyaddr 1 1. 서론 소켓을사용하여비연결형모델로통신을하기위한함수와그외의함수 함수 의미 recvfrom 비연결형모델에서소켓을통해메시지를수신한다. sendto 비연결형모델에서소켓을통해메시지를송신한다.

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 16: ioctl 을활용한 LED 제어디바이스드라이버 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 ioctl() 을활용법배우기 커널타이머와 ioctl 을활용하여 LED 제어용디바이스드라이브작성하기 2 IOCTL 을이용한드라이버제어 ioctl() 함수활용 어떤경우에는읽는용도로만쓰고,

More information

Chap06(Interprocess Communication).PDF

Chap06(Interprocess Communication).PDF Interprocess Communication 2002 2 Hyun-Ju Park Introduction (interprocess communication; IPC) IPC data transfer sharing data event notification resource sharing process control Interprocess Communication

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 인터넷프로토콜 5 장 데이터송수신 (3) 1 파일전송메시지구성예제 ( 고정크기메시지 ) 전송방식 : 고정크기 ( 바이너리전송 ) 필요한전송정보 파일이름 ( 최대 255 자 => 255byte 의메모리공간필요 ) 파일크기 (4byte 의경우최대 4GB 크기의파일처리가능 ) 파일내용 ( 가변길이, 0~4GB 크기 ) 메시지구성 FileName (255bytes)

More information

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4 Introduction to software design 2012-1 Final 2012.06.13 16:00-18:00 Student ID: Name: - 1 - 0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x

More information

좀비프로세스 2

좀비프로세스 2 Signal & Inter-Process Communication Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 좀비프로세스 2 좀비프로세스 (zombie process) 좀비프로세스란프로세스종료후메모리상에서사라지지않는프로세스 좀비프로세스의생성이유. 자식프로세스는부모프로세스에게실행결과에대한값을반환해야한다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 (Host) set up : Linux Backend RS-232, Ethernet, parallel(jtag) Host terminal Target terminal : monitor (Minicom) JTAG Cross compiler Boot loader Pentium Redhat 9.0 Serial port Serial cross cable Ethernet

More information

휠세미나3 ver0.4

휠세미나3 ver0.4 andromeda@sparcs:/$ ls -al dev/sda* brw-rw---- 1 root disk 8, 0 2014-06-09 18:43 dev/sda brw-rw---- 1 root disk 8, 1 2014-06-09 18:43 dev/sda1 brw-rw---- 1 root disk 8, 2 2014-06-09 18:43 dev/sda2 andromeda@sparcs:/$

More information

API 매뉴얼

API 매뉴얼 PCI-DIO12 API Programming (Rev 1.0) Windows, Windows2000, Windows NT and Windows XP are trademarks of Microsoft. We acknowledge that the trademarks or service names of all other organizations mentioned

More information

Microsoft PowerPoint - lab14.pptx

Microsoft PowerPoint - lab14.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. Keypad Device Control in Embedded Linux HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착되어있다. 2 Keypad Device Driver

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 소켓프로그래밍활용 IT CookBook, 유닉스시스템프로그래밍 학습목표 소켓인터페이스를활용한다양한프로그램을작성할수있다. 2/23 목차 TCP 기반프로그래밍 반복서버 동시동작서버 동시동작서버-exec함수사용하기 동시동작서버-명령행인자로소켓기술자전달하기 UDP 프로그래밍 3/23 TCP 기반프로그래밍 반복서버 데몬프로세스가직접모든클라이언트의요청을차례로처리 동시동작서버

More information

Microsoft PowerPoint - 09-Pipe

Microsoft PowerPoint - 09-Pipe 9. 파이프 상명대학교소프트웨어학부 파이프 시그널은이상한사건이나오류를처리하는데는이용하지만, 한프로세스로부터다른프로세스로대량의정보를전송하는데는부적합하다. 파이프 한프로세스를다른관련된프로세스에연결시켜주는단방향의통신채널 2 pipe() Usage #include int pipe(int filedes[2]); 3 < ex_1.c > #include

More information

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

MySQL-Ch10

MySQL-Ch10 10 Chapter.,,.,, MySQL. MySQL mysqld MySQL.,. MySQL. MySQL....,.,..,,.,. UNIX, MySQL. mysqladm mysqlgrp. MySQL 608 MySQL(2/e) Chapter 10 MySQL. 10.1 (,, ). UNIX MySQL, /usr/local/mysql/var, /usr/local/mysql/data,

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

bn2019_2

bn2019_2 arp -a Packet Logging/Editing Decode Buffer Capture Driver Logging: permanent storage of packets for offline analysis Decode: packets must be decoded to human readable form. Buffer: packets must temporarily

More information

Microsoft PowerPoint 웹 연동 기술.pptx

Microsoft PowerPoint 웹 연동 기술.pptx 웹프로그래밍및실습 ( g & Practice) 문양세강원대학교 IT 대학컴퓨터과학전공 URL 분석 (1/2) URL (Uniform Resource Locator) 프로토콜, 호스트, 포트, 경로, 비밀번호, User 등의정보를포함 예. http://kim:3759@www.hostname.com:80/doc/index.html URL 을속성별로분리하고자할경우

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

Microsoft PowerPoint - chap6 [호환 모드]

Microsoft PowerPoint - chap6 [호환 모드] 제 6 장프로세스 (Process) 숙대창병모 1 내용 프로세스시작 / 종료 명령중인수 / 환경변수 메모리배치 / 할당 비지역점프 숙대창병모 2 프로세스시작 / 종료 숙대창병모 3 Process Start Kernel exec system call user process Cstart-up routine call return int main(int argc,

More information

untitled

untitled while do-while for break continue while( ) ; #include 0 i int main(void) int meter; int i = 0; while(i < 3) meter = i * 1609; printf("%d %d \n", i, meter); i++; return 0; i i< 3 () 0 (1)

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

More information

Discrete Mathematics

Discrete Mathematics 컴퓨터특강 () 2005 년봄학기 문양세컴퓨터과학과강원대학교자연과학대학 PING 원격지컴퓨터의상태 (accessible 여부 ) 를확인 $ ping host-name // alive or dead check $ ping s host-name // packet 송수신확인 Page 2 TELNET (1/4) telnet 은원격지에있는상대방컴퓨터에자신의컴퓨터를접속하여,

More information

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Example 3.1 Files 3.2 Source code 3.3 Exploit flow

More information

Mango220 Android How to compile and Transfer image to Target

Mango220 Android How to compile and Transfer image to Target Mango220 Android How to compile and Transfer image to Target http://www.mangoboard.com/ http://cafe.naver.com/embeddedcrazyboys Crazy Embedded Laboratory www.mangoboard.com cafe.naver.com/embeddedcrazyboys

More information

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (t

학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (t 학번 : 이름 : 1. 다음파일트리구조를가진유닉스시스템이있다. / /bin/ /home/ /home/taesoo/ /home/taesoo/downloads /usr/ /usr/lib/ /usr/local/lib /media 모든폴더에파일이하나도없다고가정했을때사용자 (taesoo) 가터미널에서다음 ls 명령입력시화면출력을예측하시오. $ ls /usr/.. $

More information

Embeddedsystem(8).PDF

Embeddedsystem(8).PDF insmod init_module() register_blkdev() blk_init_queue() blk_dev[] request() default queue blkdevs[] block_device_ops rmmod cleanup_module() unregister_blkdev() blk_cleanup_queue() static struct { const

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 06 파일 I/O 로봇 SW 교육원 3 기 학습목표 2 저수준파일입출력함수를사용핛수있다. 리눅스파일시스템을이해핚다. 다양핚파일입출력실습을통해프로그램능력을향상핚다. 파일디스크립터 3 파일디스크립터를통해파일의 I/O처리 음이아닊정수 표준입력, 표준출력, 표준에러의파일서술자 unistd.h STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO

More information

Microsoft PowerPoint - IOControl [호환 모드]

Microsoft PowerPoint - IOControl [호환 모드] 목차 Input/Output Control I/O Control Mechanism mmap function munmap function RAM Area Access LED Control 4 digits 7 Segment Control Text LCD Control 1 2 I/O Control Mechanism (1) I/O Control Mechanism (2)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Sensor Device Jo, Heeseung Sensor 실습 HBE-SM5-S4210 에는근접 / 가속도 / 컴파스센서가장착 각센서들을사용하기위한디바이스드라이버와어플리케이션을작성 2 근접 (Proximity) 센서 HBE-SM5-S4210 Camera Module 근접센서디바이스 근접센서는사물이다른사물에접촉되기이전에가까이접근하였는지를검출할목적으로사용 일반적으로생활에서자동문이나엘리베이터,

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 06 저수준파일입출력 로봇 SW 교육원 최상훈 (shchoi82@gmail.com) 학습목표 2 저수준파일입출력함수 리눅스파일시스템의이해 다양한파일입출력실습을통한프로그램능력향상 파일시스템 3 리눅스파일시스템의특징 / 로시작하는트리구조 / (root) usr home bin local bin lib 열린파일에대한커널내부자료구조 4 프로세스테이블 파일테이블

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D313939392D382E687770>

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D313939392D382E687770> i ii iii iv v vi 1 2 3 4 가상대학 시스템의 국내외 현황 조사 가상대학 플랫폼 개발 이상적인 가상대학시스템의 미래상 제안 5 웹-기반 가상대학 시스템 전통적인 교수 방법 시간/공간 제약을 극복한 학습동기 부여 교수의 일방적인 내용전달 교수와 학생간의 상호작용 동료 학생들 간의 상호작용 가상대학 운영 공지사항,강의록 자료실, 메모 질의응답,

More information

Secure Programming Lecture1 : Introduction

Secure Programming Lecture1 : Introduction Malware and Vulnerability Analysis Lecture3-2 Malware Analysis #3-2 Agenda 안드로이드악성코드분석 악성코드분석 안드로이드악성코드정적분석 APK 추출 #1 adb 명령 안드로이드에설치된패키지리스트추출 adb shell pm list packages v0nui-macbook-pro-2:lecture3 v0n$

More information

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures

A Hierarchical Approach to Interactive Motion Editing for Human-like Figures 단일연결리스트 (Singly Linked List) 신찬수 연결리스트 (linked list)? tail 서울부산수원용인 null item next 구조체복습 struct name_card { char name[20]; int date; } struct name_card a; // 구조체변수 a 선언 a.name 또는 a.date // 구조체 a의멤버접근 struct

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 UNIX 및실습 6 장. 파일접근권한관리하기 1 6 장. 파일접근권한관리하기 학습목표 파일의속성과접근권한의개념을이해한다. 접근권한을변경하는방법을익힌다. 접근권한을상속하고초기에설정하는방법을익힌다. 2 01. 파일의속성 다중사용자시스템의특징 여러사람이하나의시스템사용 다른사람이내파일을읽거나수정, 삭제할수없도록보안기능필요 다른사용자의무단접근으로부터자신의파일을보호하는기능으로파일에접근권한을부여하여권한만큼만파일을사용하도록함

More information

untitled

untitled CAN BUS RS232 Line CAN H/W FIFO RS232 FIFO CAN S/W FIFO TERMINAL Emulator COMMAND Interpreter PROTOCOL Converter CAN2RS232 Converter Block Diagram > +- syntax

More information

KEY 디바이스 드라이버

KEY 디바이스 드라이버 KEY 디바이스드라이버 임베디드시스템소프트웨어 I (http://et.smu.ac.kr et.smu.ac.kr) 차례 GPIO 및 Control Registers KEY 하드웨어구성 KEY Driver 프로그램 key-driver.c 시험응용프로그램 key-app.c KEY 디바이스드라이버 11-2 GPIO(General-Purpose Purpose I/O)

More information

<4D F736F F F696E74202D20C1A63137C0E520B5BFC0FBB8DEB8F0B8AEBFCD20BFACB0E1B8AEBDBAC6AE>

<4D F736F F F696E74202D20C1A63137C0E520B5BFC0FBB8DEB8F0B8AEBFCD20BFACB0E1B8AEBDBAC6AE> 쉽게풀어쓴 C 언어 Express 제 17 장동적메모리와연결리스트 이번장에서학습할내용 동적메모리할당의이해 동적메모리할당관련함수 연결리스트 동적메모리할당에대한개념을이해하고응용으로연결리스트를학습합니다. 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것

More information

UI TASK & KEY EVENT

UI TASK & KEY EVENT T9 & AUTOMATA 2007. 3. 23 PLATFORM TEAM 정용학 차례 T9 개요 새로운언어 (LDB) 추가 T9 주요구조체 / 주요함수 Automata 개요 Automata 주요함수 추후세미나계획 질의응답및토의 T9 ( 2 / 30 ) T9 개요 일반적으로 cat 이라는단어를쓸려면... 기존모드 (multitap) 2,2,2, 2,8 ( 총 6번의입력

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 얇지만얇지않은 TCP/IP 소켓프로그래밍 C 2 판 4 장 UDP 소켓 제 4 장 UDP 소켓 4.1 UDP 클라이언트 4.2 UDP 서버 4.3 UDP 소켓을이용한데이터송싞및수싞 4.4 UDP 소켓의연결 UDP 소켓의특징 UDP 소켓의특성 싞뢰할수없는데이터젂송방식 목적지에정확하게젂송된다는보장이없음. 별도의처리필요 비연결지향적, 순서바뀌는것이가능 흐름제어 (flow

More information