实例介绍
RTEMS的posix_users文档的原创翻译。
Table of contents Preface……………………………………………………………27 Acknowledgements…… ………………………27 1 Process Creation and Execution manager………… 29 1.1 Introduction……………………29 1.2 Background……………… ……………………30 13 Operations… 1.4 Directives…………………………… 30 1.4.1fork- Create a process…………………… 31 1.4.2exec- Execute a file……………32 1.4.3 exeCv- Execute a file∴… ……33 1.4.4exec|e- Execute a file∴……………………………34 1.4.5 execve- Execute a file…… 35 1.4.6 execlp-Execute a File. .......,.... .....,.....36 14.7 execvp- Execute a file…… …37 1.4.8 pthread atfork-Register Fork Handlers …………38 1.4.9wait- Wait for Process terminatⅰon……………39 14.10 waitpid- Wait for process termination………………40 1.4.11exit- Terminate a process…… …41 2 Signal Manager.n.eoo.oo 43 2.1 Introduction……… ……43 2.2 Background 44 2.2.1 Signals ………………………………44 22.2 Signal Delivery…… 45 2.3 Operations………………………46 23.1 Signal Set Management………… 46 2.3.2 Blocking Until Signal Generation …46 2.3.3 Sending a signal 24 Directives………………………………47 241 sigaddset- Add a signal to a signal Set…………………48 2.4.2 sigdelset - Delete a Signal from a Signal Set 49 24.3 sigfillset- Fill a Signal Set……… 50 244 sigismember- Is Signal a member of a signal Set……………51 2.4.5 sigemptyset- Empty a Signal S 52 24.6 sigaction- Examine and Change Signal Action……………53 24.7 pthread kil- Send a signal to a thread……………… 56 2.4.8 sigprocmask- Examine and Change Process blocked Signals..57 2.4.9 pthread sigmask -Examine and Change thread blocked Signals.59 2.4.10 kill -Send a signal to a process……61 2. 4.11 sigpending-Examine Pending Signals. .................,.....62 2412 sigsuspend- Wait for a Signa|…… ………………63 24.13 pause- Suspend process execution……………………………………64 24.14 sIgwaIt- Synchronously accept a signal……… 2.4.15 sigwaitinfo- Synchronously accept a signal....,,,,...66 2.4.16 sigtimedwait- Synchronously Accept a Signal with Timeout.. 68 2.4.17 sigqueue-Queue a Signal to a process .......... 70 2.4.18 alarm- Schedu| e alarm……………… …72 2.4.19 alarm- Schedule alarm in microseconds……………73 3 Process Environment Manager 75 3.1 Introduction……………………… 75 32 Background…… ……76 3.2. 1 Users and groups ………76 322 User and Group Names……………… ·········· 77 3.2.3 Environment variab|es…… 3.3 Operations………78 331 Accessing User and Group lds……………………………78 3.3.2 Accessing Environment Variables 3.4 Directives 79 3.4.1 getpid -Get Process ID 3.4.2 getppid- Get Parent Process ID ..........,................,.....81 3.4.3 getuid -Get User ID 82 344 geteuid- Get Effective User ID……… 83 3.4.5 getgid -Get Real Group ID ··········:····· ……84 346 getegid- Get Effective Group|D…… .·········:::::::·:············· 3.4.7 setuid- Set User ID 86 348 setgid- Set Group ID…………… 3.4.9 getgroups-Get Supplementary Group IDs.. …88 3.4.10 getlogin-Get User Name 89 34.1 getlogin r- Reentrant get user name………90 3.4.12 getpgrp-Get Process Group ID ·,中··· 91 34.13 setid- Create Session and set Process group|D…………92 34.14 setpgid- Set Process Group ID for Job Control…………93 3.4.15 uname -Get System Name. 94 3.4.16 times-Get process times ………95 34.17 getenv- Get Envir。 nment Variables… 96 3.4.18 steny- Set environment variables…………97 3.4.19 ctermid- Generate termina| Pathname…………98 3.4.20 ttyname- Determine terminal device name………99 3421 ttyname r- Reentrant Determine terminal device Name………100 3.4.22 isatty - Determine if File descriptor is terminal.. 101 3.4.23 syscon -Get Configurable System Variables...,...102 4 Files and Directories Manager 103 4.1| ntroduction……… …103 4.2 Background… ……………105 4.2.1 Path Name evaluation 105 4.30 perations…105 4.4 Directives………………………… …106 4.4.1 opendir- Open a Directory…………………………107 4.4.2 readdir- Reads a directory………… 109 4.4.3 rewinddir-Resets the readdir( pointer ······· ………111 4.4.4 scandir -Scan a directory for matching entries. ...........112 4.4.5 telldir-Return current location in directory stream . ..........113 4.4.6 closedir- Ends directory read operation……………………………114 4.4.7 chdir-Changes the current working directory......... 115 4.4.8 chdir- Changes the current working directory…………117 4.4.9 getcwd- Gets current working directory………119 4.4.10open- Opens a file………………121 4.4.11 creat- Create a new file or rewrite an existing one……………125 4.4.12 umask- Sets a file creation mask 127 4.4.13 ink- Creates a link to a file 128 4.4.14 symlink- Creates a symbolic link to a file…………130 4.4.15 readlink -obtain the name of a symbolic link destination. 132 4. 4.16 mkdir-Makes a direct 134 4.4.17 mkfifo-Makes a FIFO special file 136 4.4.18 unlink-Removes a directory entry 138 4.4.19 rmdir- Delete a directory………140 4.4.20 rename- Renames a file …………………142 4.4.21stat- Gets informatⅰ on about a file………… 145 4.4.22 fstat- Gets file status……………147 4.4.23 Istat- Gets file status…… …148 4.4.24 access-Check permissions for a file ·· ………………149 4.4.25 chmod-Changes file mode ……151 4.4.26 fchmod- Changes permissions of a file…………153 4.4.27 getdents- Get directory entries…………………155 44.28 chown- Changes the owner and/ or group of a file.……………157 4.4.29 utime-Change access and / or modification times of an inode. 159 4.4.30 truncate- truncate a file to a specified length……… 160 4.4.31 truncate- truncate a file to a specified length……………162 4.4.32 pathconf- Gets configuration values for files……………164 4.4.33 fpathconf- Gets configuration values for files…………167 4.4.34 mknod- create a directory…… …170 5 nput and Output Primitives Manager……173 51 Introduction……………………………………………173 5.2 Background ·174 5.3 Operations…… ……174 5.4 Directives…… 175 54.1pipe- Create an inter- Process channel………………176 54.2dup- Duplicates an open file descriptor…………………177 54.3dup2- Duplicates an open file descriptor………178 5.4.4 close- Closes a file…… 180 5.4.5 read- Reads from a file... 181 5.4.6 write- Writes to a file .,.. 184 5.4.7 fcntl -Manipulates an open file descriptor 186 54.8|seek- Reposition read/ write file offset………………190 5.4.9 fsync -Synchronize file complete in-core state with that on disk 192 5.4.10 fdatasync- Synchronize file in-core data with that on disk………193 5.4.11sync- Schedule file system updates……………195 5.4.12 mount- Mount a file system……………196 5.4.13 unmount- Unmount file systems………197 5.4.14 ready- Vectored read from a file 中····· …………198 5.4.15 write- Vectored write to a file …………………200 5.4.16 aio read Asynchronous read 202 5.4.17 aio write - Asynchronous Write ..................,...203 54.18lio| Isto- List directed i/O………………………………………204 5.4.19 aio error- Retrieve Error Status of Asynchronous l/O Operation 205 5.4.20 aio return -Retrieve return Status asynchronous I/0 Operation 206 5.4.21 aio cancel -Cancel Asynchronous l/o Request …207 54.22aio_ suspend- Wait for Asynchronous I/o Request………208 5.4.23 aio fsync Asynchronous File Synchronization …………209 6 Device- and class- Specific Functions Manager ...,. 211 6.1 Introduction………………………………………………211 6.2 Background 212 6.3 Operations……… ……212 6.4 Directives……… …212 6.4.1 ctgetispeed- Reads terminal input baud rate………213 6.4.2 cfgetospeed-Reads terminal output baud rate.... 214 643 cfsetispeed- Sets terminal input baud rate……… ……215 6.4.4 cfsetospeed- Sets terminal output baud rate ……216 64.5 tcgetattr-Gets terminal attributes………… …………217 6.4.6 tcsetattr-Set terminal attributes . . ,, . 6.4.7 tcsendbreak -Sends a break to a terminal 219 6.4.8 tcdrain-Waits for all output to be transmitted to the terminal. 220 6.4.9 flush- Discards terminal data……… 221 6.4.10 tcflow -Suspends/ restarts terminal output. …222 6.4.11 tcgetpgrp-Gets foreground process group ID......223 64.12 tcsetpgrp- Sets foreground process group|D………224 7 Language-Specific Services for the C Programming Language Manager ……225 7.1| introductⅰon… ………225 7.2 Background…… …226 7.3 Operations 226 7.4 Directives…………………………………… 227 7.4.1 setlocale- Set the current locale………………228 7.4.2 fileno -obtain File descriptor Number for this file . ., ,.,,,,,.... 229 7.4.3 fopen- Associate Stream with File descriptor.. ……230 744 flockfile- Acquire Ownership of File stream……………231 7.4.5 ftrylockfile- Poll to Acquire Ownership of File stream....232 7.4.6 funlockfile- Release ownership of file stream…………233 7.4.7 getc unlocked- Get Character without Locking……………234 7.4.8 getchar unlocked- Get Character from stdin without Locking. 235 7.4.9 putc unlocked - Put Character without Locking....,...236 7.4.10 putchar_ unlocked -Put Character to stdin without Locking. ..237 7.4.11 etmp- Save Context for non - local|Goto…………………238 7.4.12 longjmp-Non- Local Jump to a Saved Context…………239 7.4.13 sigsetjmp- Save Context with Signal Status for Non-Local Goto 240 7.4.14 siglongimp-Non- Local Jump with Signal Status to a Saved context 241 7.4.15 toset- Initialize time conversion informatⅰon………242 7.4.16 strtok r- Reentrant Extract Token from String…………………243 7.4.17 asctime r- reentrant struct tm to ascll time conversion ·244 7. 4.18 ctime r- Reentrant time t to ascll time conversion.,,. ,.,.. 245 7.4.19 mtime_ r-Reentrant UTC Time Conversion...,,,,,,, .. 246 7. 4.20 localtime r-Reentrant local time conversion.. …………247 7.4.21 rand r- Reentrant random number generation…………248 8 System Databases manager 249 8.1 Introduction…………………… …249 8.2 Background……… …249 8.3 Operations… 250 8.4 Directives…………………………………………………………………………250 841 getgrgid- Get Group File Entry for ID……………………251 8.4.2 getgrgid_r-Reentrant Get Group File Entry for ID.......252 843 getgrnam- Get Group File Entry for name…………………253 844 getgrnam_r- Reentrant Get Group File Entry for Name…………254 8.4.5 getpwuid -Get Password File Entry for UID …255 8.4.6 getpwuid r-Reentrant Get Password File entry for UID ......256 8.4.7 getpwnam-Password file entry for Name.....,...257 8.4.8 getpwnam r-Reentrant Get Password File entry for Name 258 9 Semaphore Manager aea. 9.1 Introduction 259 9.2 Background 260 9.2.1 Theory 260 9.2.2sem t structure... …260 9.2.3 Building a Semaphore attribute se 260 3 Operations… ……………………261 9.3.1 Using as a Binary semaphore.. 261 9.4 Directives………………………………………………………261 94.1 sem init- Initialize an unnamed semaphore………… …262 9.4.2 sem destroy- Destroy an unnamed semaphore …………264 9.4.3 sem open-Open a named semaphore ………265 9.4.4 sem close-Close a named semaphore.......,..267 9.4.5 sem unlink -Unlink a semaphore... 看自 268 9.4.6 sem wait-Wait on a Semaphore. ……………270 947 sem trywait-Non- blocking Wait on a Semaphore……………271 9.4.8 sem timedwait-Wait on a semaphore for a specified Time. 272 949 sem_ post- Unlock a Semaphore……274 9.4.10 sem_ getvalue-Get the value of a semaphore ……275 utex Manager……… 277 10.1 Introduction ………277 10.2 Background…… …………278 10.2.1 Mutex Attributes……… …………………278 10.2.2 PTHREAD MUTE|N| TIALIZER…… 279 10.3 Operations ……279 10.4 Services……… 279 10.4.1 pthread mutexattr init-Initialize a mutex attribute set.280 10.4.2 pthread mutexattr destroy -Destroy a mutex Attribute Set.281 10.4.3 pthread mutexattr setprotocol Set the blocking Protocol. 282 10.4.4 pthread mutexattr_ getprotocol -Get the blocking Protocol..284 10.4.5 pthread mutexattr setprioceiling- Set the Priority Ceiling.285 1046 pthread mutexattr getprioceiling- Get the priority Ceiling………286 10.4.7 pthread mutexattr setpshared Set the visibility.,...287 1048 pthread mutexattr getpshared- Get the visibility…………288 1049 pthread_ mutex_init- Initialize a mutex…………289 10.4.10 pthread mutex destroy-Destroy a mutex …290 10.4.11 pthread mutex lock-Lock a Mutex ··········:····· …291 0.4.12 pthread mutex trylock- Poll to lock a mutex ..,,,,.,. 292 10.4.13 pthread_ mutex timedlock-Lock a Mutex with Timeout..293 10.4.14 pthread mutex unlock -Unlock a Mutex …………294 10.4.15 pthread mutex setprioceiling- Dynamically Set the Priority Ceiling ……………………………295 10.4.16 pthread mutex getprioceiling -Get the current Priority Ceiling 296 11 Condition Variable Manager …297 11.1 Introduction………………297 11.2 Background…………………………………………298 11.3 Operations… ……………298 11.4 Directives……………………………………………………………………………………298 11.4.1 pthread condattr init -Initialize a Condition Variable Attribute Set ………………………………299 11.4.2 pthread_condattr- destroy -Destroy a Condition Variable Attribute Set……………… ………………300 11.4.3 pthread condattr setpshared -Set Process Shared Attribute. 301 11.4.4 pthread condattr getpshared -Get Process Shared Attribute. ...302 11.4.5 pthread cond_init -Initialize a Condition variable. .........303 114.6 pthread_ cond destroy- Destroy a Condition variable……………304 11.4.7 pthread cond signal -Signal a Condition Variabl 305 11.4.8 pthread cond broadcast - broadcast a Condition variable. ...306 11.4.9 pthread cond wait Wait on a Condition Variable 307 11.4.10 pthread cond timedwait-Wait with Timeout a Condition Variable …308 emory Management Manager omeooooo.oooe 309 12.1 Introduction…… …309 12.2 Background… …310 12.3 Operations…………………………… ……310 124 Directives………………………310 124.1 mlockall - Lock the Address space of a process………311 12.4.2 munlockall -Unlock the address space of a process …312 12.4.3 mlock-Lock a Range of the process Address space 313 12.4.4 munlock -Unlock a Range of the process Address space .....314 124.5mmap- Map Process Addresses to a Memory object………315 12. 4.6 munmap- Unmap previously Mapped Addresses …316 2.4.7 mprotect-Change memory protection .. ……317 12.4.8 msync -Memory object Synchronization., ……318 2.4.9 shm open- Open a shared memory object……………319 12. 4.10 shm_ unlink- Remove a Shared Memory object …320 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论