INTRO

Section: ¸®´ª½º ÇÁ·Î±×·¡¸Ó ¸Å´º¾ó (2)
Updated: 1996³â 5¿ù 2ÀÏ
Index
Return to Main Contents
 

À̸§

intro - ½Ã½ºÅÛ ÄÝ¿¡ ´ëÇÑ ¼Ò°³  

¼³¸í

¿©±â¼­´Â ¸®´ª½º ½Ã½ºÅÛ ÄÝÀ» ¼³¸íÇÑ´Ù. ¸®´ª½º 2.0¿¡ ÀÖ´Â 164°³ÀÇ ½Ã½ºÅÛ ÄÝÀÇ ¸ñ·ÏÀº syscalls(2)¸¦ º¸¾Æ¶ó.  

Á÷Á¢ È£ÃâÇϱâ

´ëºÎºÐÀÇ °æ¿ì, ½Ã½ºÅÛ ÄÝÀ» Á÷Á¢ È£ÃâÇÒ ÇÊ¿ä´Â ¾øÁö¸¸, ´ç½Å¿¡°Ô ÇÊ¿äÇÑ ÇÔ¼ö°¡ Ç¥ÁØ C ¶óÀ̺귯¸®¿¡ ±¸ÇöµÇÁö ¾Ê´Â °æ¿ìµµ ÀÖ´Ù.  

»ç¿ë¹ý

#include <linux/unistd.h>

_syscall ¸ÅÅ©·Î

¿øÇÏ´Â ½Ã½ºÅÛ ÄÝ

 

¼³Á¤

½Ã½ºÅÛ ÄÝ¿¡ ´ëÇØ ¾Ë¾Æ¾ß ÇÏ´Â Áß¿äÇÑ »çÇ×Àº ÇÁ·ÎÅäŸÀÔÀÌ´Ù. ÀÎÀÚÀÇ °³¼ö, ÀÎÀÚÀÇ Å¸ÀÔ°ú ÇÔ¼ö ¸®ÅÏ Å¸ÀÔÀ» ¾Ë ÇÊ¿ä°¡ ÀÖ´Ù. ½Ã½ºÅÛÀ¸·ÎÀÇ ½ÇÁ¦ÀûÀΠȣÃâÀ» ´õ ½±°Ô ÇØÁÖ´Â 6°³ÀÇ ¸ÅÅ©·Î°¡ ÀÖ´Ù. ´ÙÀ½°ú °°Àº Çü½ÄÀÌ´Ù:

_syscallX(type,name,type1,arg1,type2,arg2,...)
X´Â 0-5, ½Ã½ºÅÛ ÄÝÀÌ ÃëÇÏ´Â ÀÎÀÚÀÇ °³¼öÀÌ´Ù.
system call
type´Â ½Ã½ºÅÛ ÄÝÀÇ ¸®ÅÏ Å¸ÀÔ
name´Â ½Ã½ºÅÛ ÄÝÀÇ À̸§
typeN´Â N¹ø° ÀÎÀÚÀÇ Å¸ÀÔ
argN´Â N¹ø° ÀÎÀÚÀÇ À̸§

ÀÌ ¸ÅÅ©·Î´Â ¸í½ÃÇÑ ÀÎÀÚ¸¦ °®´Â name À̸§ÀÇ ÇÔ¼ö¸¦ ¸¸µç´Ù. ¼Ò½º ÆÄÀÏ¿¡ _syscall()À» Æ÷ÇÔ½ÃÅ°¸é, nameÀ¸·Î ½Ã½ºÅÛ ÄÝÀ» È£ÃâÇÒ ¼ö ÀÖ´Ù.  

¿¹Á¦


#include <stdio.h>
#include <linux/unistd.h>       /* _syscallX ¸ÅÅ©·Î/°ü·ÃµÈ °Í */
#include <linux/kernel.h>       /* struct sysinfo */

_syscall1(int, sysinfo, struct sysinfo *, info);

/* ÁÖÀÇ: nroff ¼Ò½º¿¡¼­ ¹Ù·Î º¹»ç¸¦ ÇÑ´Ù¸é, printf ¹®¿¡¼­ 
¿©ºÐÀÇ ¹é½½·¹½¬(\)¸¦ Áö¿ö¾ßÇÑ´Ù. */

int main(void) { struct sysinfo s_info; int error; error = sysinfo(&s_info); printf("code error = %d\n", error); printf("Uptime = %ds\nLoad: 1 min %d / 5 min %d / 15 min %d\n" "RAM: total %d / free %d / shared %d\n" "Memory in buffers = %d\nSwap: total %d / free %d\n" "Number of processes = %d\n", s_info.uptime, s_info.loads[0], s_info.loads[1], s_info.loads[2], s_info.totalram, s_info.freeram, s_info.sharedram, s_info.bufferram, s_info.totalswap, s_info.freeswap, s_info.procs); return(0); }
 

¿¹Á¦ Ãâ·Â

code error = 0
uptime = 502034s
Load: 1 min 13376 / 5 min 5504 / 15 min 1152
RAM: total 15343616 / free 827392 / shared 8237056
Memory in buffers = 5066752
Swap: total 27881472 / free 24698880
Number of processes = 40
 

ÁÖÀÇ

_syscall() ¸ÅÅ©·Î´Â ÇÁ·ÎÅäŸÀÔÀ» ¸¸µéÁö´Â ¾Ê´Â´Ù. ƯÈ÷ C++ »ç¿ëÀÚ¶ó¸é, ÇÁ·ÎÅäŸÀÔÀº »ý¼ºÇؾ߸¸ ÇÒ °ÍÀÌ´Ù.

½Ã½ºÅÛ ÄÝÀº ¾ç¼ö³ª À½¼ö ¿¡·¯ Äڵ常À» ¸®ÅÏÇؾ߸¸ ÇÏÁö´Â ¾Ê´Â´Ù. ¾î¶»°Ô ¿¡·¯¸¦ ¸®ÅÏÇÏ´ÂÁö¸¦ ¾Ë·Á¸é ¼Ò½º¸¦ ÀÐÀ» ÇÊ¿ä°¡ ÀÖ´Ù. º¸Åë À½¼ö´Â Ç¥ÁØ ¿¡·¯ ÄÚµåÀÌ´Ù. Áï, -EPERM. _syscall() ¸ÅÅ©·Î´Â rÀÌ À½¼ö°¡ ¾Æ´Ò ¶§ r¸¦ ¸®ÅÏÇÏÁö¸¸, rÀÌ À½¼öÀÏ ¶§ -r¸¦ errno¿¡ ¼³Á¤ÇÏ°í -1À» ¸®ÅÏÇÑ´Ù. ¿¡·¯ Äڵ忡 ´ëÇؼ­´Â errno(3)À» º¸¾Æ¶ó.

mmap°ú °°Àº ¸î¸îÀÇ ½Ã½ºÅÛ ÄÝÀº 5°³ ÀÌ»óÀÇ ÀÎÀÚ¸¦ °®´Â´Ù. ÀÌ´Â ÀÎÀÚ¸¦ ½ºÅÿ¡ ³Ö°í ÀÎÀÚ ºí·°À» Æ÷ÀÎÅ͸¦ ³Ñ±â´Â ¹æ¹ýÀ¸·Î 󸮵ȴÙ.

½Ã½ºÅÛ ÄÝÀ» Á¤ÀÇÇÒ ¶§, ÀÎÀÚ´Â ¹Ýµå½Ã °ªÀ̳ª Æ÷ÀÎÅÍ(±¸Á¶Ã¼ °°Àº ÁýÇÕÇüÀÇ °æ¿ì)·Î ³Ñ°ÜÁ®¾ß¸¸ ÇÑ´Ù.  

ȣȯ

½Ã½ºÅÛ ÄÝÀÌ ¾î¶² À¯´Ð½º º¯ÇüÀ̳ª Ç¥ÁØ°ú ȣȯÀÌ µÇ´ÂÁö ³ªÅ¸³»´Â ÄÚµå´Â ´ÙÀ½°ú °°´Ù:
SVr4
½Ã½ºÅÛ V ¸±¸®Áî 4 À¯´Ð½º (System V Release 4 Unix), "Programmer's Reference Manual: Operating System API (Intel processors)" (Prentice-Hall 1992, ISBN 0-13-951294-2)¿¡ ¼³¸íµÇÀÖ´Ù.
SVID
½Ã½ºÅÛ V ÀÎÅÍÆäÀ̽º Á¤ÀÇ (System V Interface Definition), "The System V Interface Definition, Fourth Edition"¿¡ ¼³¸íµÇÀÖ°í, ÀÌ´Â ftp://ftp.fpk.novell.com/pub/unix-standards/svid¿¡ Æ÷½ºÆ®½ºÅ©¸³Æ® ÆÄÀÏ·Î ÀÖ´Ù.
POSIX.1
IEEE 1003.1-1990 part 1, º°Äª ISO/IEC 9945-1:1990s, º°Äª "IEEE Portable Operating System Interface for Computing Environments", Donald LewineÀÇ "POSIX Programmer's Guide" (O'Reilly & Associates, Inc., 1991, ISBN 0-937175-73-0)¿¡ ¼³¸íµÇÀÖ´Ù.
POSIX.1b
IEEE Std 1003.1b-1993 (POSIX.1b standard)´Â Æ÷ÅÍºí ¿î¿µ üÁ¦¸¦ À§ÇÑ ½Ç½Ã°£ ÀÎÅÍÆäÀ̽º¸¦ ¼³¸íÇÑ´Ù, º°Äª ISO/IEC 9945-1:1996, Biil O. GallmeisterÀÇ "Programming for the real world - POSIX.4" (O'Reilly & Associates, Inc. ISBN 1-56592-074-0)¿¡ ¼³¸íµÇÀÖ´Ù.
SUS, SUSv2
´ÜÀÏ À¯´Ð½º ¸í¼¼ (Single Unix Specification). (X/Open°ú The Open Group¿¡¼­ ¸¸µé¾ú´Ù. http://www.UNIX-systems.org/version2/¸¦ ÂüÁ¶Ç϶ó.)
4.3BSD/4.4BSD
¹öŬ¸® À¯´Ð½ºÀÇ 4.3°ú 4.3 ¹èÆ÷º». 4.4BSD´Â 4.3ºÎÅÍ È£È¯¼ºÀÌ À¯ÁöµÇ¾ú´Ù.
V7
¹öÀü 7 (Version 7), º§ ¿¬±¸¼ÒÀÇ ¿øÁ¶ À¯´Ð½º.
 

ÆÄÀÏ

/usr/include/linux/unistd.h  

°ü·Ã Ç׸ñ

errno(3)  

¿ªÀÚ

ÀÓÁ¾±Õ <hermes44@secsm.org>, 2000³â 4¿ù 19ÀÏ


 

Index

À̸§
¼³¸í
Á÷Á¢ È£ÃâÇϱâ
»ç¿ë¹ý
¼³Á¤
¿¹Á¦
¿¹Á¦ Ãâ·Â
ÁÖÀÇ
ȣȯ
ÆÄÀÏ
°ü·Ã Ç׸ñ
¿ªÀÚ

This document was created by man2html, using the manual pages.
Time: 08:07:01 GMT, March 25, 2004