-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAPUE.mm
3064 lines (3060 loc) · 213 KB
/
APUE.mm
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<map version="1.0.1">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1338637055049" ID="ID_143495120" MODIFIED="1498552114655" TEXT="APUE">
<node CREATED="1338637081000" FOLDED="true" ID="ID_640748604" MODIFIED="1503901178469" POSITION="right" TEXT="unbuffered IO (POSIX)">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<node CREATED="1338638811768" ID="ID_1420511453" MODIFIED="1375431940364" TEXT="header">
<node CREATED="1338637134048" ID="ID_418835484" MODIFIED="1341892737423" TEXT="<unistd.h>">
<node CREATED="1338637168938" ID="ID_425199589" MODIFIED="1338637168938" TEXT="standard symbolic constants and types"/>
<node CREATED="1338637228910" ID="ID_259807824" MODIFIED="1338637249355" TEXT="STDIN_FILENO"/>
<node CREATED="1338637233896" ID="ID_1142684653" MODIFIED="1338637244861" TEXT="STDOUT_FILENO"/>
<node CREATED="1338637215866" ID="ID_1465760884" MODIFIED="1338637225714" TEXT="STDERR_FILENO"/>
</node>
<node CREATED="1338637479192" ID="ID_1989948994" MODIFIED="1341892739605" TEXT="<limits.h>">
<node CREATED="1338637506041" ID="ID_661969641" MODIFIED="1338637506041" TEXT="implementation-defined constants"/>
<node CREATED="1338637562000" ID="ID_671543073" MODIFIED="1338637567436" TEXT="OPEN_MAX">
<node CREATED="1338637571626" ID="ID_582298855" MODIFIED="1338637672588" TEXT="process can open OPEN_MAX+1 files at most"/>
<node CREATED="1338637684700" ID="ID_1710478800" MODIFIED="1338637716267" TEXT="file descriptors range from 0 through OPEN_MAX"/>
</node>
</node>
<node CREATED="1338639047051" ID="ID_1905888153" MODIFIED="1338639074970" TEXT="<sys/types.h>"/>
<node CREATED="1338639045242" ID="ID_1113121751" MODIFIED="1338639060783" TEXT="<sys/stat.h>"/>
<node CREATED="1338637857080" ID="ID_1644592417" MODIFIED="1338728798373" TEXT="<fcntl.h> ">
<node CREATED="1338637878256" ID="ID_1204748916" MODIFIED="1338637878256" TEXT="file control options"/>
<node CREATED="1338638247435" FOLDED="true" ID="ID_1816578570" MODIFIED="1374565372942" TEXT="file open flags">
<node CREATED="1338638362753" ID="ID_1192687196" MODIFIED="1341884928259" TEXT="essential">
<node CREATED="1338638271436" ID="ID_1758951476" MODIFIED="1338638283364" TEXT="O_RDONLY"/>
<node CREATED="1338638290583" ID="ID_624769379" MODIFIED="1338638299982" TEXT="O_WRONLY"/>
<node CREATED="1338638303687" ID="ID_886016896" MODIFIED="1338638307838" TEXT="O_RDWR"/>
</node>
<node CREATED="1338638403470" ID="ID_963865183" MODIFIED="1363191123468" TEXT="optional">
<node CREATED="1338638419932" ID="ID_487678898" MODIFIED="1338638435166" TEXT="O_APPEND"/>
<node CREATED="1338638435587" ID="ID_179847820" MODIFIED="1338638438939" TEXT="O_CREAT"/>
<node CREATED="1338638467715" ID="ID_86886944" MODIFIED="1338638475884" TEXT="O_TRUNC"/>
<node CREATED="1338638439286" ID="ID_1400112512" MODIFIED="1338638456591" TEXT="O_EXCL"/>
<node CREATED="1338638486970" FOLDED="true" ID="ID_1683581176" MODIFIED="1363191126468" TEXT="O_SYNC">
<node CREATED="1363190287716" ID="ID_1660992136" MODIFIED="1363190733761" TEXT="Have each write wait for physical I/O to complete. "/>
<node CREATED="1363190735982" ID="ID_1449205080" MODIFIED="1363190853591" TEXT="This causes each write to wait for the data fo be written to disk before returning. "/>
<node CREATED="1363190858636" ID="ID_1201951453" MODIFIED="1363190955830" TEXT="in other case,copy new data into buffer cache."/>
</node>
<node CREATED="1363190552665" FOLDED="true" ID="ID_734397012" MODIFIED="1363191127475" TEXT="O_ASYNC">
<node CREATED="1363190991507" ID="ID_1975900493" MODIFIED="1363191005931" TEXT="asynchronized IO"/>
</node>
<node CREATED="1338638504692" FOLDED="true" ID="ID_1454998514" MODIFIED="1363191128529" TEXT="O_NOCTTY">
<node CREATED="1363190248943" ID="ID_1119359052" MODIFIED="1363190272312" TEXT="not controling terminal"/>
</node>
<node CREATED="1338638510975" FOLDED="true" ID="ID_614933203" MODIFIED="1363191129428" TEXT="O_NONBLOCK">
<node CREATED="1363190278028" ID="ID_100154832" MODIFIED="1363190285709" TEXT="nonblocking"/>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1338638791151" FOLDED="true" ID="ID_971797200" MODIFIED="1375431960926" TEXT="function">
<node CREATED="1338638914732" ID="ID_981656375" MODIFIED="1341892647265" TEXT="int open(const char *pathname, int oflag .... /* , mode t mode */ );">
<node CREATED="1338640176854" ID="ID_1988766910" MODIFIED="1338640602942" TEXT="open(pathname,O_RDONLY);">
<node CREATED="1338639578699" ID="ID_739055899" MODIFIED="1338640457885" TEXT="open a file for read, generate error if file does not exist"/>
</node>
<node CREATED="1338640268378" ID="ID_41727674" MODIFIED="1341892655663" TEXT="open(pathname,O_WRONLY|O_CREAT,mode);">
<node CREATED="1338639746878" ID="ID_735675190" MODIFIED="1338640363633" TEXT="open a file for write,create it if file does not exists,
otherwise just open file already existing"/>
</node>
<node CREATED="1338640370964" ID="ID_1147658715" MODIFIED="1338640502696" TEXT="open(pathname,O_WRONLY|O_CREAT|O_TRUNC,mode);">
<node CREATED="1338639897696" ID="ID_1864418119" MODIFIED="1338640446342" TEXT="open a file for write,if the file exists,open it and
truncate its size to 0,otherwise create a new file"/>
</node>
<node CREATED="1338640461788" ID="ID_1011631307" MODIFIED="1338640496258" TEXT="open(pathname,O_WRONLY|O_CREAT|O_APPEND,mode);">
<node CREATED="1338639987512" ID="ID_614475156" MODIFIED="1338640546670" TEXT="open a file for write,if the file exists,open it and seek its 
pointor to the end of file,otherwise create a new file"/>
</node>
<node CREATED="1338640549227" ID="ID_1284992251" MODIFIED="1338640622725" TEXT="open(pahtname,O_WRONLY|O_CREAT|O_EXCL,mode);">
<node CREATED="1338640095721" ID="ID_362903588" MODIFIED="1338640599120" TEXT="create a file for write,if the file exists already,
generate error, otherwise create a new file"/>
</node>
</node>
<node CREATED="1338639300549" ID="ID_1890730798" MODIFIED="1341892660681" TEXT="int creat(const char *pathname, mode_t mode);">
<node CREATED="1338639485162" ID="ID_1945980091" MODIFIED="1338639564652" TEXT="equivalent to open(pathname,O_WRONLY|O_CREAT|O_TRUNC,mode);"/>
</node>
<node CREATED="1338640698458" ID="ID_1797736224" MODIFIED="1338640721145" TEXT="int close (int filedes) ; "/>
<node CREATED="1338640801792" ID="ID_382643923" MODIFIED="1341892665658" TEXT="off_t lseek (int filedes, off_t offset, int whence) ; ">
<node CREATED="1338640856498" ID="ID_1469930942" MODIFIED="1338640861923" TEXT="whence">
<node CREATED="1338640876730" ID="ID_1878498146" MODIFIED="1338640880554" TEXT="SEEK_SET">
<node CREATED="1338640912836" ID="ID_672688724" MODIFIED="1338640923261" TEXT="begin of file"/>
</node>
<node CREATED="1338640880920" ID="ID_1242541559" MODIFIED="1338640885834" TEXT="SEEK_CUR">
<node CREATED="1338640927548" ID="ID_1411132779" MODIFIED="1338640935945" TEXT="current position of file"/>
</node>
<node CREATED="1338640886168" ID="ID_679418835" MODIFIED="1338640894350" TEXT="SEEK_END">
<node CREATED="1338640937553" ID="ID_1703838887" MODIFIED="1338640941082" TEXT="end of file"/>
</node>
</node>
</node>
<node CREATED="1338641226270" ID="ID_407834183" MODIFIED="1338641526487" TEXT="int read(int filedes, char *buff, unsigned nbytes); "/>
<node CREATED="1338641740516" ID="ID_1145365765" MODIFIED="1338641795629" TEXT="ssize_t write(int filedes, const void *buff, size_t nbytes);"/>
<node CREATED="1338639315897" ID="ID_431999587" MODIFIED="1338641803979" TEXT="open,create,close,read,write return -1 on error"/>
<node CREATED="1338796847993" ID="ID_807362399" MODIFIED="1338796891891" TEXT="<unistd. h>void sync (void) ;">
<node CREATED="1338796956481" ID="ID_1207894114" MODIFIED="1338797026668" TEXT="write dirty block in buffer cache to disk"/>
</node>
<node CREATED="1338796847993" ID="ID_205764871" MODIFIED="1338796895604" TEXT="<unistd. h>int fsync (int filedes) ;"/>
</node>
<node CREATED="1338642434921" ID="ID_1556299629" MODIFIED="1375431925388" TEXT="file I/O implement">
<node CREATED="1338642498913" ID="ID_1020971923" MODIFIED="1363191425411" TEXT="file descriptor table (u area)">
<icon BUILTIN="full-1"/>
<node CREATED="1338642538633" ID="ID_1126099437" MODIFIED="1363191429040" TEXT="file table">
<icon BUILTIN="full-2"/>
<node CREATED="1338642549384" ID="ID_1672547298" MODIFIED="1363191438724" TEXT="v-node(i-node) list">
<icon BUILTIN="full-3"/>
<node CREATED="1338642567802" ID="ID_1347448214" MODIFIED="1363191445079" TEXT="disk blocks">
<icon BUILTIN="full-4"/>
</node>
</node>
</node>
</node>
<node CREATED="1338642640976" ID="ID_1458417004" MODIFIED="1338642650290" TEXT="file sharing">
<node CREATED="1338642776765" ID="ID_842730631" MODIFIED="1338643150086" TEXT="different file descriptors,same file table entries">
<node CREATED="1338643173252" ID="ID_1900414900" MODIFIED="1338643196471" TEXT="int dup (int filedes) ; ">
<node CREATED="1338643470514" ID="ID_775245686" MODIFIED="1338643564606" TEXT="copy filedes's file table entry pointer to lowest available file descritor"/>
</node>
<node CREATED="1338643198815" ID="ID_626762706" MODIFIED="1338643220065" TEXT="int dup2(int filedes,int filedes2);">
<node CREATED="1338643573349" ID="ID_915453463" MODIFIED="1338643682135" TEXT="close filedes2,then copy filedes's file table entry 
pointer to lowest available file descritor"/>
</node>
<node CREATED="1363191522843" ID="ID_85134465" MODIFIED="1363191524244" TEXT="Both return: new file descriptor if OK, -1 on error "/>
</node>
<node CREATED="1338642712002" ID="ID_1968267083" MODIFIED="1338643151957" TEXT="different file table entres ,same v-node"/>
<node CREATED="1338642680807" ID="ID_1085869172" MODIFIED="1339172881850" TEXT="different pathname(directory entry) ,same inode index"/>
</node>
<node CREATED="1338645252555" ID="ID_127324154" MODIFIED="1338645424627" TEXT="int fcntl(int filedes, int cmd , .../* int arg */ ); ">
<node CREATED="1338645426685" ID="ID_1044661340" MODIFIED="1338645442711" TEXT="duplicate file descriptor">
<node CREATED="1338645820045" ID="ID_847237458" MODIFIED="1338645869205" TEXT="fcntl(fd,F_DUPFD,n)">
<node CREATED="1338645872561" ID="ID_775041607" MODIFIED="1338645926024" TEXT="dup fd to descriptor equal or greater than n"/>
</node>
</node>
<node CREATED="1338645444242" ID="ID_262634947" MODIFIED="1338645699976" TEXT="get/set file descriptor flags">
<node CREATED="1338646023094" ID="ID_648315932" MODIFIED="1338646042220" TEXT="cmd=F_GETFD/F_SETFD"/>
<node CREATED="1338646042720" ID="ID_86506659" MODIFIED="1338646092767" TEXT="only FD_CLOEXEC is defined"/>
</node>
<node CREATED="1338645459027" ID="ID_1405213530" MODIFIED="1338645705629" TEXT="get/set file status flags">
<node CREATED="1338646109988" ID="ID_1179143799" MODIFIED="1363192170122" TEXT="cmd=F_GETFL">
<node CREATED="1338646136931" ID="ID_956846081" MODIFIED="1338646294147" TEXT="O_ACCMODE used to obtain the access mode bit 
O_RDONLY,O_WRONLY,ON_RDWR">
<node CREATED="1363192172462" ID="ID_1072696469" MODIFIED="1363192176556" TEXT="Unfortunately, the three access mode flags (O_RDONLY, O_WRONLY, and O_RDWR) are not separate bits that can be tested. (As we mentioned ear- lier, these three often have the values 0, 1, and 2, respectively, for historical reasons; also these three values are mutually exclusive--a file can have only one of the three enabled.) Therefore we must first use the O_ACCMODE mask fo obtain the access mode bits and then compare the result against any of the three values. "/>
</node>
</node>
<node CREATED="1363192179689" ID="ID_281324774" MODIFIED="1363192190647" TEXT="cmd=F_SETFL">
<node CREATED="1363192191910" ID="ID_871909494" MODIFIED="1363192225678" TEXT="The only flags that can be changed are">
<node CREATED="1363192227556" ID="ID_278981556" MODIFIED="1363192239420" TEXT="O_APPEND"/>
<node CREATED="1363192239832" ID="ID_47134998" MODIFIED="1363192247454" TEXT="O_NONBLOCK"/>
<node CREATED="1363192247794" ID="ID_1884407164" MODIFIED="1363192258864" TEXT="O_SYNC"/>
<node CREATED="1363192259102" ID="ID_1215711035" MODIFIED="1363192264044" TEXT="O_ASYNC"/>
</node>
</node>
</node>
<node CREATED="1338645690417" ID="ID_1069714640" MODIFIED="1338645731081" TEXT="get/set asynchronous IO ownership">
<node CREATED="1363192336033" ID="ID_1284658543" MODIFIED="1363192361822" TEXT="F_GETOWN">
<node CREATED="1363192362810" ID="ID_1767444576" MODIFIED="1363192363916" TEXT="Get the process ID or process group ID currently receiving the SIGIO and SIGURG signals. "/>
</node>
<node CREATED="1363192382120" ID="ID_213730015" MODIFIED="1363192387348" TEXT="F_SETOWN">
<node CREATED="1363192388337" ID="ID_422492941" MODIFIED="1363192389633" TEXT="Set the process ID or process group ID to receive the SIGIO and SIGURG signals. A positive arg specifies a process ID. A negative arg implies a process group ID equal to the absolute value of arg. "/>
</node>
</node>
<node CREATED="1338645737354" ID="ID_1332558625" MODIFIED="1338645745473" TEXT="get/set record lock"/>
</node>
</node>
<node CREATED="1338639150708" ID="ID_8920670" MODIFIED="1375431935565" TEXT="misc">
<node CREATED="1338639177305" ID="ID_1756867882" MODIFIED="1338639189245" TEXT="PATH_MAX"/>
<node CREATED="1338639189525" ID="ID_1960610422" MODIFIED="1338639192312" TEXT="NAME_MAX"/>
<node CREATED="1338639192621" ID="ID_1102485188" MODIFIED="1338639227518" TEXT="_POSIX_NO_TRUNC"/>
<node CREATED="1338639237969" ID="ID_905980349" MODIFIED="1338639244430" TEXT="ENAMETOOLONG"/>
</node>
<node CREATED="1338642869205" ID="ID_1199434635" MODIFIED="1341892630700" TEXT="utility">
<node CREATED="1338642890664" ID="ID_12674521" MODIFIED="1338642892244" TEXT="od">
<node CREATED="1338642925061" ID="ID_288719590" MODIFIED="1338642925061" TEXT="dump files in octal and other formats"/>
</node>
</node>
</node>
<node CREATED="1338637081998" FOLDED="true" ID="ID_1029354476" MODIFIED="1457088083103" POSITION="right" TEXT="buffered IO (C Standard Libary)">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<node CREATED="1338800410580" ID="ID_1589389692" MODIFIED="1363190004097" TEXT="buffering">
<node CREATED="1338801092372" ID="ID_1515962288" MODIFIED="1338801264575" TEXT="#include <stdio.h> "/>
<node CREATED="1338801254667" ID="ID_1615250955" MODIFIED="1338801254667" TEXT="void setbuf(FILE *fp, char *buff);">
<node CREATED="1338801366184" ID="ID_505816062" MODIFIED="1338801369946" TEXT="buff">
<node CREATED="1338801373274" ID="ID_40240280" MODIFIED="1338801395350" TEXT="NULL">
<node CREATED="1338801398070" ID="ID_337204880" MODIFIED="1338801408275" TEXT="unbuffered"/>
</node>
<node CREATED="1338801409685" ID="ID_791193892" MODIFIED="1338801431527" TEXT="buff[BUFSIZ]">
<node CREATED="1338801438630" ID="ID_469011435" MODIFIED="1338801474731" TEXT="fully buffered or line buffered"/>
</node>
</node>
</node>
<node CREATED="1338801266874" ID="ID_402093280" MODIFIED="1397272700291" TEXT="int setvbuf(FILE *fp, char *buff, int mode, size_t size); ">
<node CREATED="1338800420618" ID="ID_1323079286" MODIFIED="1338801505588" TEXT="fully buffered">
<node CREATED="1338800487940" ID="ID_34018836" MODIFIED="1338801060355" TEXT="default"/>
<node CREATED="1338801516794" ID="ID_302342715" MODIFIED="1338801561756" TEXT="mode=_IOFBF"/>
</node>
<node CREATED="1338800432108" ID="ID_1635687383" MODIFIED="1338801296532" TEXT="line buffered">
<node CREATED="1338800525778" ID="ID_952261751" MODIFIED="1338800565849" TEXT="stdin stdout(interactive)"/>
<node CREATED="1338801520125" ID="ID_676149399" MODIFIED="1338801572473" TEXT="mode=_IOLBF"/>
</node>
<node CREATED="1338800436577" ID="ID_737064901" MODIFIED="1338801286579" TEXT="unbuffered">
<node CREATED="1338800528812" ID="ID_1470931605" MODIFIED="1338800547222" TEXT="stderr(default)"/>
<node CREATED="1338801523830" ID="ID_1865543183" MODIFIED="1338801584185" TEXT="mode=_IONBF"/>
</node>
</node>
<node CREATED="1338801641005" ID="ID_1838798590" MODIFIED="1338801657980" TEXT="int fflush(FILE*fp);">
<node CREATED="1339853417041" ID="ID_1885903720" MODIFIED="1339853450204" TEXT="if fp==NULL, flush all output stream"/>
</node>
</node>
<node CREATED="1338801667892" ID="ID_859923928" MODIFIED="1363223691025" TEXT="open stream">
<node CREATED="1338801675045" ID="ID_1632086452" MODIFIED="1338801745232" TEXT="FILE*fopen(const char*pathname, const char * type);"/>
<node CREATED="1338801745844" ID="ID_165447621" MODIFIED="1338801811898" TEXT="FILE*freopen(const char*pathname, const char*type,FILE*fp);"/>
<node CREATED="1338801812200" ID="ID_81170830" MODIFIED="1338801841359" TEXT="FILE*fdopen(int fd,const char*type);">
<node CREATED="1338817220847" ID="ID_484020520" MODIFIED="1338817239899" TEXT="only r w a+ take effect"/>
</node>
<node CREATED="1338816236320" ID="ID_775836499" MODIFIED="1339403788291" TEXT="type">
<node CREATED="1338816765188" ID="ID_927380296" MODIFIED="1338816777169" TEXT="r">
<node CREATED="1338816805300" ID="ID_568484335" MODIFIED="1338816819230" TEXT="O_RDONLY"/>
</node>
<node CREATED="1338816778052" ID="ID_1229928108" MODIFIED="1338816778955" TEXT="w">
<node CREATED="1338816844150" ID="ID_433867928" MODIFIED="1338816878580" TEXT="O_WRONLY|O_CREAT|O_TRUNC"/>
</node>
<node CREATED="1338816779584" ID="ID_1998771831" MODIFIED="1338816779977" TEXT="a">
<node CREATED="1338816844150" ID="ID_131007715" MODIFIED="1338816895213" TEXT="O_WRONLY|O_CREAT|O_APPEND"/>
</node>
<node CREATED="1338816780317" ID="ID_909198921" MODIFIED="1338816783901" TEXT="r+">
<node CREATED="1338816932943" ID="ID_1870407267" MODIFIED="1338816970005" TEXT="O_RDWR"/>
</node>
<node CREATED="1338816784192" ID="ID_219214369" MODIFIED="1338816785914" TEXT="w+">
<node CREATED="1338816971452" ID="ID_1515836325" MODIFIED="1338816989790" TEXT="O_RDWR|O_CREAT|O_TRUNC"/>
</node>
<node CREATED="1338816786220" ID="ID_1271860717" MODIFIED="1338816789396" TEXT="a+">
<node CREATED="1338816991742" ID="ID_712648646" MODIFIED="1338817008905" TEXT="O_RDWR|O_CREAT|O_APPEND"/>
</node>
<node CREATED="1338816730590" ID="ID_296899652" MODIFIED="1339403794344" TEXT="restrictions">
<node CREATED="1338816333058" ID="ID_902687870" MODIFIED="1338816742242" TEXT="file must already exist">
<node CREATED="1338816532493" ID="ID_130730654" MODIFIED="1338816541001" TEXT="r">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816238409" ID="ID_366819271" MODIFIED="1338816546845" TEXT="w">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816239786" ID="ID_1010317549" MODIFIED="1338816548537" TEXT="a">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816240693" ID="ID_937343286" MODIFIED="1338816544591" TEXT="r+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816242641" ID="ID_1193408112" MODIFIED="1338816550641" TEXT="w+">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816245191" ID="ID_1321205688" MODIFIED="1338816551965" TEXT="a+">
<icon BUILTIN="button_cancel"/>
</node>
</node>
<node CREATED="1338816347962" ID="ID_28720158" MODIFIED="1338816347962" TEXT="previous contents of file discarded">
<node CREATED="1338816597592" ID="ID_670339201" MODIFIED="1338816604141" TEXT="r">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816238409" ID="ID_489414428" MODIFIED="1338816606372" TEXT="w">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816239786" ID="ID_30268881" MODIFIED="1338816608514" TEXT="a">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816240693" ID="ID_1477025101" MODIFIED="1338816615984" TEXT="r+">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816242641" ID="ID_55142609" MODIFIED="1338816621495" TEXT="w+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816245191" ID="ID_1773557124" MODIFIED="1338816638292" TEXT="a+">
<icon BUILTIN="button_cancel"/>
</node>
</node>
<node CREATED="1338816360042" ID="ID_1044485127" MODIFIED="1338816360042" TEXT="stream can be read">
<node CREATED="1338816625637" ID="ID_262534847" MODIFIED="1338816641214" TEXT="r">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816238409" ID="ID_1294774625" MODIFIED="1338816642901" TEXT="w">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816239786" ID="ID_403236003" MODIFIED="1338816644884" TEXT="a">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816240693" ID="ID_1672159718" MODIFIED="1338816646777" TEXT="r+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816242641" ID="ID_101369685" MODIFIED="1338816648448" TEXT="w+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816245191" ID="ID_1160995434" MODIFIED="1338816649962" TEXT="a+">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node CREATED="1338816372684" ID="ID_1354410060" MODIFIED="1338816372684" TEXT="stream can be written">
<node CREATED="1338816653315" ID="ID_1212225865" MODIFIED="1338816658242" TEXT="r">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816238409" ID="ID_657335877" MODIFIED="1338816660976" TEXT="w">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816239786" ID="ID_298967103" MODIFIED="1338816663216" TEXT="a">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816240693" ID="ID_90103546" MODIFIED="1338816664789" TEXT="r+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816242641" ID="ID_691772861" MODIFIED="1338816666737" TEXT="w+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816245191" ID="ID_687770414" MODIFIED="1338816668078" TEXT="a+">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node CREATED="1338816372685" ID="ID_1623899439" MODIFIED="1338816372685" TEXT="stream can be written only at end">
<node CREATED="1338816674652" ID="ID_1346587256" MODIFIED="1338816682907" TEXT="r">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816239786" ID="ID_1171068379" MODIFIED="1338816685163" TEXT="a">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816240693" ID="ID_1388275871" MODIFIED="1338816687449" TEXT="r+">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1338816238409" ID="ID_1035866914" MODIFIED="1338816698875" TEXT="w">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816242641" ID="ID_995247555" MODIFIED="1358933286248" TEXT="w+">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1338816245191" ID="ID_294824434" MODIFIED="1338816693346" TEXT="a+">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
<node CREATED="1338817312409" ID="ID_1881272569" MODIFIED="1339403787152" TEXT="access permissions">
<node CREATED="1338817326449" ID="ID_1621545788" MODIFIED="1338817365941" TEXT="S_IRUSR |S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH"/>
</node>
</node>
<node CREATED="1338817376079" FOLDED="true" ID="ID_1351150672" MODIFIED="1338817408462" TEXT="close stream">
<node CREATED="1338817388364" ID="ID_1465316213" MODIFIED="1338817406690" TEXT="int fclose(FILE*fp);"/>
</node>
<node CREATED="1338817421641" ID="ID_792612529" MODIFIED="1339224240892" TEXT="read&write stream">
<node CREATED="1338817436072" FOLDED="true" ID="ID_496230140" MODIFIED="1338818546974" TEXT="char-by-char">
<node CREATED="1338817507893" ID="ID_1065408924" MODIFIED="1338818459327" TEXT="input">
<node CREATED="1338817525498" ID="ID_1570209922" MODIFIED="1338817525498" TEXT="#include <stdio.h>"/>
<node CREATED="1338817525500" ID="ID_1231732612" MODIFIED="1338817535879" TEXT="int getc(FILE *fp);">
<node CREATED="1338817615038" ID="ID_760566269" MODIFIED="1338817623998" TEXT="can be macro"/>
<node CREATED="1338817939869" ID="ID_386399926" MODIFIED="1338817945355" TEXT="more efficient"/>
</node>
<node CREATED="1338817525501" ID="ID_463542191" MODIFIED="1338817540943" TEXT="int fgetc(FILE *fp);">
<node CREATED="1338817625986" ID="ID_1975437954" MODIFIED="1338817632633" TEXT="can't be macro"/>
</node>
<node CREATED="1338817525502" FOLDED="true" ID="ID_1756453454" MODIFIED="1338818545506" TEXT="int getchar(void);">
<node CREATED="1338818469826" ID="ID_133139280" MODIFIED="1338818486372" TEXT="getc(stdin);"/>
<node COLOR="#ff0000" CREATED="1338818120788" ID="ID_392087104" MODIFIED="1338818309530">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
All three return:next character if OK, EOF on end of file or error  
</p>
</body>
</html></richcontent>
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1338818230649" ID="ID_260039046" MODIFIED="1338818230649" TEXT="#include <stdio.h>"/>
<node CREATED="1338818230649" ID="ID_766293909" MODIFIED="1338818230649" TEXT="int ferror(FILE *);"/>
<node CREATED="1338818230650" ID="ID_381370431" MODIFIED="1338818230650" TEXT="int feof(FILE *);">
<node CREATED="1338818230650" ID="ID_563340191" MODIFIED="1338818268648" TEXT="Both return:nonzero(true) if condition is true 0(false) otherwise"/>
</node>
<node CREATED="1338818230651" ID="ID_940508061" MODIFIED="1338818230651" TEXT="void clearerr(FILE *);"/>
</node>
</node>
<node CREATED="1338818319123" ID="ID_350793846" MODIFIED="1338818357748" TEXT="int ungetc(int c, FILE*);">
<node CREATED="1338818319125" ID="ID_1751951712" MODIFIED="1338818350740" TEXT="returns: c if OK, EOF on error"/>
</node>
</node>
<node CREATED="1338818391828" ID="ID_493282689" MODIFIED="1338818393668" TEXT="output">
<node CREATED="1338818404597" ID="ID_425584068" MODIFIED="1338818404597" TEXT="#include <stdio.h>"/>
<node CREATED="1338818404598" ID="ID_1201227349" MODIFIED="1338818404598" TEXT="int putc(int c, FILE *);">
<node CREATED="1338818447266" ID="ID_153890777" MODIFIED="1338818451140" TEXT="can be macro"/>
</node>
<node CREATED="1338818404599" ID="ID_576036826" MODIFIED="1338818404599" TEXT="int fputc(int c, FILE *);">
<node CREATED="1338818437972" ID="ID_1271068301" MODIFIED="1338818445071" TEXT="can't be macro"/>
</node>
<node CREATED="1338818404600" ID="ID_1640237903" MODIFIED="1338818404600" TEXT="int putchar (int c) ;">
<node CREATED="1338818404601" ID="ID_1552931066" MODIFIED="1338818456375" TEXT="all three return: c if OK, EOF on error"/>
<node CREATED="1338818490126" ID="ID_1233196553" MODIFIED="1338818503393" TEXT="putc(c,stdout);"/>
</node>
</node>
</node>
<node CREATED="1338817461990" FOLDED="true" ID="ID_148562358" MODIFIED="1338819924343" TEXT="line-by-line">
<node CREATED="1338818550476" FOLDED="true" ID="ID_849712951" MODIFIED="1338819077814" TEXT="input">
<node CREATED="1338818553756" ID="ID_883555174" MODIFIED="1338818553756" TEXT="#include <stdio. h>"/>
<node CREATED="1338818553757" ID="ID_785329250" MODIFIED="1338818574393" TEXT="char *fgets(char *buf,int n, FILE *);">
<node CREATED="1338818788680" ID="ID_1359076312" MODIFIED="1338818856389" TEXT="get no more than n-1 chars"/>
<node CREATED="1338818856722" ID="ID_933598447" MODIFIED="1338818890716" TEXT="terminated with null byte('\0')"/>
<node CREATED="1338818892323" ID="ID_1902185397" MODIFIED="1338818940383" TEXT="store newline"/>
</node>
<node CREATED="1338818553758" ID="ID_1199266836" MODIFIED="1338818553758" TEXT="char *gets (char *buf) ;">
<node CREATED="1338818553759" ID="ID_291024604" MODIFIED="1338818615497" TEXT="both return: buf if OK, NULL on end of file or error"/>
<node CREATED="1338818942716" ID="ID_53492501" MODIFIED="1338818948915" TEXT="deprecated"/>
<node CREATED="1338818949595" ID="ID_1573173220" MODIFIED="1338819027069" TEXT="get a line,can cause buffer overflow"/>
<node CREATED="1338819029098" ID="ID_1251207102" MODIFIED="1338819038825" TEXT="remove newline"/>
</node>
</node>
<node CREATED="1338819079021" ID="ID_373094498" MODIFIED="1338819081596" TEXT="output">
<node CREATED="1338819096666" ID="ID_1829467538" MODIFIED="1338819096666" TEXT="#include <stdio. h>"/>
<node CREATED="1338819096667" ID="ID_1656791849" MODIFIED="1338819108092" TEXT="int fputs(const char *str,FILE *);"/>
<node CREATED="1338819096667" ID="ID_1641358389" MODIFIED="1338819096667" TEXT="int puts (const char *str);">
<node CREATED="1338819096668" ID="ID_1354955650" MODIFIED="1338819124092" TEXT="both return: nonnegative value if OK, EOF on error"/>
</node>
</node>
</node>
<node CREATED="1338817466269" ID="ID_1881549682" MODIFIED="1339224244713" TEXT="block-by-block">
<node CREATED="1338819857475" ID="ID_1335569747" MODIFIED="1338819865414" TEXT="input">
<node CREATED="1338819857476" ID="ID_1389188275" MODIFIED="1338819904976" TEXT="size_t fread(void *ptr, size_t size, size_t nobj, FILE *);"/>
</node>
<node CREATED="1338819870587" ID="ID_684907402" MODIFIED="1338819873105" TEXT="output">
<node CREATED="1338819857478" ID="ID_1643610050" MODIFIED="1338819919839" TEXT="size_t fwrite(const void *ptr, size_t size, size_t nobj, FILE *);">
<node CREATED="1338819857478" ID="ID_841873777" MODIFIED="1339224252791" TEXT="both return: number of objects read or written">
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1338819938257" ID="ID_900543614" MODIFIED="1340466217658" TEXT="position stream">
<node CREATED="1338820091735" ID="ID_1858213938" MODIFIED="1338820099596" TEXT="long">
<node CREATED="1338820130865" ID="ID_224287580" MODIFIED="1338820130865" TEXT="#include <stdio. h>"/>
<node CREATED="1338820130867" ID="ID_1095382383" MODIFIED="1338820130867" TEXT="long ftell (FILE *) ;">
<node CREATED="1338820130867" ID="ID_1604833369" MODIFIED="1338820143489" TEXT="returns: current file position indicator if OK, -1L on error"/>
</node>
<node CREATED="1338820130868" ID="ID_712146296" MODIFIED="1338820130868" TEXT="int fseek(FILE *, long offset, int whence);">
<node CREATED="1338820130869" ID="ID_1711569111" MODIFIED="1338820130869" TEXT="Returns: 0 if OK, nonzero on error"/>
<node CREATED="1338820177253" ID="ID_187737526" MODIFIED="1338820263389" TEXT="whence">
<node CREATED="1338820269467" ID="ID_1656326635" MODIFIED="1338820278357" TEXT="SEEK_SET"/>
<node CREATED="1338820278877" ID="ID_533502281" MODIFIED="1338820283215" TEXT="SEEK_CUR"/>
<node CREATED="1338820283551" ID="ID_814250487" MODIFIED="1338820286223" TEXT="SEEK_END"/>
</node>
</node>
<node CREATED="1338820130870" ID="ID_1263288342" MODIFIED="1338820130870" TEXT="void rewind (FILE *) ;"/>
</node>
<node CREATED="1338820092506" ID="ID_1172715283" MODIFIED="1338820114175" TEXT="fpos_t">
<node CREATED="1338820351626" ID="ID_673686864" MODIFIED="1338820351626" TEXT="#include <stdio.h>"/>
<node CREATED="1338820351627" ID="ID_1239795956" MODIFIED="1338820363391" TEXT="int fgetpos(FILE *,fpos_t *pos) ;"/>
<node CREATED="1338820351628" ID="ID_1466617170" MODIFIED="1338820377291" TEXT="int fsetpos(FILE *,const fpos_t *pos);">
<node CREATED="1338820351630" ID="ID_1767912310" MODIFIED="1338820392855" TEXT="both return: 0 if OK, nonzero on error"/>
</node>
</node>
</node>
<node CREATED="1338820413858" FOLDED="true" ID="ID_1092024099" MODIFIED="1339853396456" TEXT="formatted IO">
<node CREATED="1338820435478" ID="ID_1684300203" MODIFIED="1338820438601" TEXT="input">
<node CREATED="1338820552060" ID="ID_569910942" MODIFIED="1338820552060" TEXT="#include <stdio.h>">
<node CREATED="1338820552061" ID="ID_208371087" MODIFIED="1338820552061" TEXT="int printf(const char *format, ...);"/>
<node CREATED="1338820552062" ID="ID_1258360863" MODIFIED="1338820552062" TEXT="int fprintf(FILE *stream, const char *format, ...);"/>
<node CREATED="1338820552062" ID="ID_603466027" MODIFIED="1338820552062" TEXT="int sprintf(char *str, const char *format, ...);"/>
<node CREATED="1338820552063" ID="ID_1091821177" MODIFIED="1338820552063" TEXT="int snprintf(char *str, size_t size, const char *format, ...);"/>
</node>
<node CREATED="1338820552064" ID="ID_16208512" MODIFIED="1338820552064" TEXT="#include <stdarg.h>">
<node CREATED="1338820552065" ID="ID_769529621" MODIFIED="1338820578025" TEXT="int vprintf(const char *format, va_list ap);"/>
<node CREATED="1338820552066" ID="ID_1489389107" MODIFIED="1338820578024" TEXT="int vfprintf(FILE *stream, const char *format, va_list ap);"/>
<node CREATED="1338820552066" ID="ID_1834654679" MODIFIED="1338820578023" TEXT="int vsprintf(char *str, const char *format, va_list ap);"/>
<node CREATED="1338820552067" ID="ID_752974167" MODIFIED="1338820578022" TEXT="int vsnprintf(char *str, size_t size, const char *format, va_list ap);"/>
</node>
</node>
<node CREATED="1338820438859" ID="ID_736451510" MODIFIED="1338820441091" TEXT="output">
<node CREATED="1338820744497" ID="ID_269448548" MODIFIED="1338820744497" TEXT="#include <stdio.h>">
<node CREATED="1338820744498" ID="ID_565068543" MODIFIED="1338820744498" TEXT="int scanf(const char *format, ...);"/>
<node CREATED="1338820744499" ID="ID_39576912" MODIFIED="1338820744499" TEXT="int fscanf(FILE *stream, const char *format, ...);"/>
<node CREATED="1338820744500" ID="ID_916205632" MODIFIED="1338820744500" TEXT="int sscanf(const char *str, const char *format, ...);"/>
</node>
<node CREATED="1338820744500" ID="ID_746888925" MODIFIED="1338820744500" TEXT="#include <stdarg.h>">
<node CREATED="1338820744501" ID="ID_1919514439" MODIFIED="1338820744501" TEXT="int vscanf(const char *format, va_list ap);"/>
<node CREATED="1338820744502" ID="ID_1371609697" MODIFIED="1338820744502" TEXT="int vsscanf(const char *str, const char *format, va_list ap);"/>
<node CREATED="1338820744503" ID="ID_1783127301" MODIFIED="1338820744503" TEXT="int vfscanf(FILE *stream, const char *format, va_list ap);"/>
</node>
</node>
</node>
<node CREATED="1338820896265" FOLDED="true" ID="ID_1677705107" MODIFIED="1339853393112" TEXT="fileno">
<node CREATED="1338820916798" ID="ID_1159023612" MODIFIED="1338820916798" TEXT="int fileno(FILE *);"/>
</node>
<node CREATED="1338821181726" FOLDED="true" ID="ID_889499206" MODIFIED="1339853391342" TEXT="temp file">
<node CREATED="1338821225233" ID="ID_482994248" MODIFIED="1338821225233" TEXT="char *tempnam(const char *dir, const char *pfx);"/>
<node CREATED="1338821246051" ID="ID_444252212" MODIFIED="1338821246051" TEXT="char *tmpnam(char *s);"/>
<node CREATED="1338821261635" ID="ID_474254587" MODIFIED="1338821261635" TEXT="FILE *tmpfile(void);"/>
</node>
<node CREATED="1338821680335" FOLDED="true" ID="ID_1007390824" MODIFIED="1457088083097" TEXT="alternatives to standard IO">
<node CREATED="1338821696927" ID="ID_1518971894" MODIFIED="1338821717243" TEXT="fio"/>
<node CREATED="1338821717607" ID="ID_362939942" MODIFIED="1338821724184" TEXT="sfio"/>
<node CREATED="1338821724813" ID="ID_601843360" MODIFIED="1457088077912" TEXT="ASI(mmap)">
<node CREATED="1338821767172" ID="ID_127271931" MODIFIED="1338821782847" TEXT="Alloc Stream Interface"/>
</node>
</node>
</node>
<node CREATED="1341233738980" FOLDED="true" ID="ID_1592264497" MODIFIED="1457088178205" POSITION="right" TEXT="Advanced IO">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<node CREATED="1363183972035" ID="ID_1877880927" MODIFIED="1363183978609" TEXT="IO mode">
<node CREATED="1363184032875" FOLDED="true" ID="ID_1181800838" MODIFIED="1363184192659" TEXT="busy-wait">
<icon BUILTIN="full-1"/>
<node CREATED="1341233893050" ID="ID_1682300774" MODIFIED="1363184055393" TEXT="monoprogramming"/>
<node CREATED="1363184058925" ID="ID_347234273" MODIFIED="1363184113620" TEXT="IO and computing serialized"/>
</node>
<node CREATED="1363184117289" ID="ID_864814042" MODIFIED="1363184136495" TEXT="blocking">
<icon BUILTIN="full-2"/>
</node>
<node CREATED="1363184139639" ID="ID_1561552708" MODIFIED="1363184150999" TEXT="nonblocking">
<icon BUILTIN="full-3"/>
</node>
<node CREATED="1363184155195" ID="ID_1540465569" MODIFIED="1363184171175" TEXT="asynchronous">
<icon BUILTIN="full-4"/>
</node>
</node>
<node CREATED="1341237063338" FOLDED="true" ID="ID_1977167150" MODIFIED="1381478581369" TEXT="record locking">
<node CREATED="1341238164101" ID="ID_226880162" MODIFIED="1357729409409" TEXT="fcntl">
<node CREATED="1341237086018" ID="ID_478362268" MODIFIED="1341238197524" TEXT="#include<sys/types.h>"/>
<node CREATED="1341237113328" ID="ID_976998802" MODIFIED="1341238197514" TEXT="#include<unistd.h>"/>
<node CREATED="1341237120418" ID="ID_425834071" MODIFIED="1341238197514" TEXT="#include<fcntl.h>"/>
<node CREATED="1341237145798" ID="ID_1525845596" MODIFIED="1341238197514" TEXT="int fcntl (int filedes, int cmd .... /* struct flock *flockptr */ ); ">
<node CREATED="1341237177068" ID="ID_1001218871" MODIFIED="1341237180860" TEXT="cmd">
<node CREATED="1341237182978" ID="ID_1510825903" MODIFIED="1341237322181" TEXT="F_GETLK">
<node CREATED="1341237349419" ID="ID_793402554" MODIFIED="1341237441191" TEXT="Determine if the lock described by flockptr is blocked by some other lock. "/>
<node CREATED="1341237479449" ID="ID_1129974988" MODIFIED="1341237505991" TEXT="if some other lock exists">
<node CREATED="1341237515930" ID="ID_1245707702" MODIFIED="1341237625592" TEXT=" flockptr is overwrited"/>
</node>
<node CREATED="1341237490859" ID="ID_1143214622" MODIFIED="1341237513912" TEXT="otherwise">
<node CREATED="1341237581970" ID="ID_1736869510" MODIFIED="1341237656452" TEXT="flockptr->l_type set to F_UNLCK,others unchanged"/>
</node>
</node>
<node CREATED="1341237322530" ID="ID_1328945968" MODIFIED="1341237328671" TEXT="F_SETLK">
<node CREATED="1341237659900" ID="ID_168468619" MODIFIED="1341237890482" TEXT="obtain lock , returns immediately with errno set to either EACCES or EAGAIN if some other lock prevents from obtaining lock."/>
</node>
<node CREATED="1341237328909" ID="ID_525218682" MODIFIED="1341237336531" TEXT="F_SETLKW">
<node CREATED="1341237874440" ID="ID_678499269" MODIFIED="1341237920902" TEXT="obtain lock, goes to sleep if some other lock prevent from obtaining lock"/>
</node>
</node>
<node CREATED="1341237208558" ID="ID_1881895460" MODIFIED="1357729448819" TEXT="flockptr">
<node CREATED="1341237216108" ID="ID_1888920116" MODIFIED="1363192749006">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
struct flock {
</p>
<p>
    short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
</p>
<p>
    off_t l_start; /* offset in bytes, relative to 1_whence */
</p>
<p>
    short l_whence; /* SEEK_SET, SEEK_CUR, or SEEK_END */
</p>
<p>
    off_t l_len; /* length, in bytes; 0 means lock to EOF */
</p>
<p>
    pid_t l_pid; /* returned with F_GETLK */
</p>
<p>
};
</p>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1341237161518" ID="ID_890983105" MODIFIED="1341238197503" TEXT="Returns: depends on cmd if OK,-1 on error "/>
</node>
<node CREATED="1341238202932" ID="ID_1681894481" MODIFIED="1357729755918" TEXT="Locks are associated with a process and a file. This has two implications. The first is obvious: when a process terminates all its locks are released. The second is far from obvious: whenever a descriptor is closed, any locks on the file referenced by that descriptor for that process are released. "/>
<node CREATED="1341238280012" ID="ID_148901281" MODIFIED="1341238282154" TEXT="Locks are never inherited by the child across a fork. "/>
<node CREATED="1341238292542" ID="ID_1693962238" MODIFIED="1341238294344" TEXT="Locks may be inherited by a new program across an exec. "/>
</node>
<node CREATED="1363184228958" FOLDED="true" ID="ID_914696221" MODIFIED="1363192768864" TEXT="IO multiplexing">
<node CREATED="1363184240446" ID="ID_1819502289" MODIFIED="1363184243574" TEXT="select">
<node CREATED="1363184267740" ID="ID_1042354335" MODIFIED="1363184366376" TEXT="#include <sys/types.h> /* fd_set data type */ 
#include <sys/time.h> /* struct timeval */ 
#include <unistd.h> /* function prototype might be here */ 
int select(int maxfdpl, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *tvptr); 
Returns: count of ready descriptors, 0 on timeout, -1 on error 
">
<node CREATED="1363184303749" ID="ID_1724210638" MODIFIED="1363184376229" TEXT="tvptr">
<node CREATED="1363184377403" ID="ID_1434006835" MODIFIED="1363184393471" TEXT="tvptr==NULL">
<node CREATED="1363184394903" ID="ID_912774625" MODIFIED="1363184415452" TEXT="Wait forever. "/>
<node CREATED="1363184418102" ID="ID_1060693959" MODIFIED="1363184477080" TEXT="can be interrupted,then return -1 with errno set to EINTR"/>
</node>
<node CREATED="1363184480416" ID="ID_1107766968" MODIFIED="1363184521131" TEXT="tvptr->tv_sec==0 && tvptr->tv.usec==0">
<node CREATED="1363184523255" ID="ID_1003360748" MODIFIED="1363184567282" TEXT="nonblocking,return immediately if no IO operations are ready"/>
</node>
<node CREATED="1363184601240" ID="ID_1704861950" MODIFIED="1363184622397" TEXT="tvptr->tv_sec!==0 || tvptr->tv.usec!=0">
<node CREATED="1363184623472" ID="ID_704635246" MODIFIED="1363184653345" TEXT="timeout"/>
<node CREATED="1363184694719" ID="ID_67198936" MODIFIED="1363184714892" TEXT="Return is made when one of the specified descriptors is ready or when the rime-out value expires. "/>
<node CREATED="1363184715648" ID="ID_1051164853" MODIFIED="1363184741485" TEXT="0 on time-out value expires"/>
<node CREATED="1363184742313" ID="ID_1074396031" MODIFIED="1363184773598" TEXT="-1 on interruption"/>
</node>
</node>
<node CREATED="1363184889921" FOLDED="true" ID="ID_307735917" MODIFIED="1363185503835" TEXT="fd_set">
<node CREATED="1363184895461" ID="ID_509721850" MODIFIED="1363184978470" TEXT="FD_ZERO(fd_set*fdset)">
<node CREATED="1363185050816" ID="ID_1184306002" MODIFIED="1363185079686" TEXT="clear all bits in fdset(init)"/>
</node>
<node CREATED="1363184979130" ID="ID_854709311" MODIFIED="1363185021749" TEXT="FD_SET(int fd,fd_set *fdset)">
<node CREATED="1363185080978" ID="ID_1465329682" MODIFIED="1363185159602" TEXT="turn on bit for fd in fd_set"/>
</node>
<node CREATED="1363184992721" ID="ID_1271504391" MODIFIED="1363185039266" TEXT="FD_CLR(int fd,fd_set *fdset)">
<node CREATED="1363185087408" ID="ID_1656211882" MODIFIED="1363185180246" TEXT="turn off bit for fd in fd_set"/>
</node>
<node CREATED="1363184997974" ID="ID_604752929" MODIFIED="1363185048557" TEXT="FD_ISSET(int fd,fd_set*fdset)">
<node CREATED="1363185094491" ID="ID_1497366803" MODIFIED="1363185217737" TEXT="test bit for fd in fd_set"/>
</node>
</node>
<node CREATED="1363185333928" ID="ID_365664696" MODIFIED="1363185350115" TEXT="readfds,writefds,exceptfds">
<node CREATED="1363185354861" FOLDED="true" ID="ID_764004916" MODIFIED="1363185362158" TEXT="usleep">
<node CREATED="1363185351305" ID="ID_1450656227" MODIFIED="1363185359502" TEXT="Any (or ail) of the middle three arguments to select (the pointers to the descriptor sets) can be null pointers, if we're not interested in that condition. If all three pointers are NULL, then we have a higher precision timer than provided by sleep. "/>
</node>
</node>
<node CREATED="1363185505791" FOLDED="true" ID="ID_1296494721" MODIFIED="1363185733450" TEXT="maxfdpl">
<node CREATED="1363185518399" ID="ID_848095732" MODIFIED="1363185539577" TEXT="The first argument to select, maxfdpl, stands for "'max fd plus I." We calculate the highest descriptor that we're interested in, in any of the three descriptor sets, add 1, and that's the first argument. We could just set the first argument to FD_SETSIZE, a constant in <sys/types. h> that specifies the maximum number of descriptors (often I/O Multiplexing 399 256 or 1024), but this value is too large for most applications. Indeed, most applications probably use between 3 and 10 descriptors. (There are applications that need many more descriptors, but these aren't the typical Unix program.) By specifying the highest descriptor that we're interested in, the kernel can avoid going through hundreds of unused bits in the three descriptor sets, looking for bits that are turned on. "/>
<node CREATED="1363185583548" ID="ID_1171404557" MODIFIED="1363185584737" TEXT="The reason we have to add 1 to the maximum descriptor number is because descriptors start at 0, and the first argument is really a count of the number of descriptors to check (starting with descriptor 0). "/>
</node>
<node CREATED="1363185734457" ID="ID_848915727" MODIFIED="1363185735659" TEXT=""ready" means. ">
<node CREATED="1363185747834" ID="ID_261087257" MODIFIED="1363185762028" TEXT="1. A descriptor in the read set (readfds) is considered ready if a read from that descriptor won't block. "/>
<node CREATED="1363185776631" ID="ID_1826673171" MODIFIED="1363185777868" TEXT="2. A descriptor in the write set (writefds) is considered ready if a write to that descriptor won't block. "/>
<node CREATED="1363185789991" ID="ID_1825419702" MODIFIED="1363185798628" TEXT="3. A descriptor in the exception set (exceptfds) is considered ready if there is an exception condition pending on that descriptor. Currently an exception condi- tion corresponds to (a) the arrival of out-of-band data on a network connection, or (b) certain conditions occurring on a pseudo terminal that has been placed into packet mode. (Section 15.10 of Stevens [1990] describes this latter condition.) "/>
</node>
<node CREATED="1363185957518" FOLDED="true" ID="ID_360102744" MODIFIED="1363189819487" TEXT="EOF">
<node CREATED="1363185953821" ID="ID_1739882279" MODIFIED="1363185963453" TEXT="If we encounter the end of file on a descriptor, that descriptor is considered readable by select. We then call read and it returns 0, the normal Unix way to signify end of file. (Many people incorrectly assume select indicates an exception condition on a descriptor when the end of file is reached.) "/>
</node>
</node>
</node>
</node>
<node CREATED="1363189830636" ID="ID_889823763" MODIFIED="1363189935881">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
#include <fcntl.h>
</p>
<p>
#include "ourhdr.h"
</p>
<p>
void set_fl(int fd, int flags)
</p>
<p>
{
</p>
<p>
    int val;
</p>
<p>
    /* flags are file status flags to turn on */
</p>
<p>
    if ( (val = fcntl(fd, F_GETFL, 0)) < 0)
</p>
<p>
          err_sys("fcntl F_GETFL error");
</p>
<p>
    val I= flags; /* turn on flags */     
</p>
<p>
    if (fcntl(fd, F_SETFL, val) < 0)
</p>
<p>
         err_sys("fcntl F_SETFL error");
</p>
<p>
}
</p>
</body>
</html></richcontent>
</node>
<node CREATED="1341283732120" ID="ID_1335444766" MODIFIED="1457088083130" TEXT="memory mapped IO">
<node CREATED="1341283750539" ID="ID_731699793" MODIFIED="1457088085969" TEXT="mmap">
<node CREATED="1341283908429" ID="ID_190168221" MODIFIED="1341283930412" TEXT="#include<sys/types.h>"/>
<node CREATED="1341283930823" ID="ID_879360502" MODIFIED="1341283955629" TEXT="#include<sys/mman.h>"/>
<node CREATED="1341283956805" ID="ID_917038823" MODIFIED="1341885344077" TEXT="void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);">
<node CREATED="1341284581178" ID="ID_1994952586" MODIFIED="1341284583457" TEXT="prot">
<node CREATED="1341284591567" ID="ID_97003155" MODIFIED="1341284600383" TEXT="PROT_READ"/>
<node CREATED="1341284600685" ID="ID_1100412528" MODIFIED="1341284606163" TEXT="PROT_WRITE"/>
<node CREATED="1341284622596" ID="ID_205813009" MODIFIED="1341284626685" TEXT="PROT_EXEC"/>
<node CREATED="1341284628438" ID="ID_1950181779" MODIFIED="1341284633822" TEXT="PROT_NONE">
<node CREATED="1341284679863" ID="ID_1789453146" MODIFIED="1341284691331" TEXT="can't be accessed"/>
</node>
</node>
<node CREATED="1341284583759" ID="ID_1122628258" MODIFIED="1341284586913" TEXT="flags">
<node CREATED="1341284700011" ID="ID_689745019" MODIFIED="1341284705208" TEXT="MAP_FIXED">
<node CREATED="1341284715042" ID="ID_1468049440" MODIFIED="1341284768193" TEXT="user specifies start addr for mapped file"/>
</node>
<node CREATED="1341284769915" ID="ID_596995236" MODIFIED="1341284788403" TEXT="MAP_SHARED">
<node CREATED="1341284797160" ID="ID_1097275380" MODIFIED="1341284884162" TEXT="store operations modify orignal mapped file"/>
</node>
<node CREATED="1341284800896" ID="ID_1985585062" MODIFIED="1341284807216" TEXT="MAP_PRIVATE">
<node CREATED="1341284886601" ID="ID_1128526342" MODIFIED="1341284933559" TEXT="a copy created,store operations just modify the copy of orignal mapped file "/>
</node>
</node>
<node CREATED="1341285035598" ID="ID_819831644" MODIFIED="1341285665369" TEXT="offset">
<node CREATED="1341285667546" ID="ID_103009520" MODIFIED="1341285756478" TEXT="offset must be a multiple of the page size">
<node CREATED="1341285667546" ID="ID_1381466438" MODIFIED="1341285789175" TEXT="(SVR4) sysconf(_SC_PAGE_SIZE)."/>
<node CREATED="1341285793175" ID="ID_514436832" MODIFIED="1341285839509" TEXT="(4.3+BSD) constant NBPG in the header <sys/parara. h>"/>
</node>
</node>
</node>
<node CREATED="1341284035858" ID="ID_1085890391" MODIFIED="1341284039963" TEXT="Returns: starting address of mapped region if OK, -1 on error "/>
<node CREATED="1341286120939" ID="ID_553847674" MODIFIED="1341886085468" TEXT="signal triggered">
<node CREATED="1341286152269" ID="ID_1210505940" MODIFIED="1341286172379" TEXT="SIGSEGV">
<node CREATED="1341286193954" ID="ID_190871733" MODIFIED="1341286193954" TEXT="Attempted write into a region mapped as read-only."/>
</node>
<node CREATED="1341286172697" ID="ID_1667818105" MODIFIED="1341286178268" TEXT="SIGBUS">
<node CREATED="1341286234287" ID="ID_627078458" MODIFIED="1341286345064" TEXT="Attempted access to a portion of the buffer that does not correspond to the file (for example, beyond the end of the file, including the case where another process has truncated the file)."/>
</node>
</node>
<node CREATED="1341286374788" ID="ID_343853064" MODIFIED="1457088159344" TEXT="inheritance">
<node CREATED="1341286414815" ID="ID_1505640876" MODIFIED="1341286460845" TEXT="memory mapped region inherited by fork"/>
<node CREATED="1341286461334" ID="ID_1442917312" MODIFIED="1341286470524" TEXT="not inherited by exec"/>
</node>
</node>
<node CREATED="1341283902244" ID="ID_1336146309" MODIFIED="1341283905943" TEXT="munmap">
<node CREATED="1341286503650" ID="ID_1479186748" MODIFIED="1341286503650" TEXT="#include <sys/types.h>"/>
<node CREATED="1341286503650" ID="ID_170058458" MODIFIED="1341286503650" TEXT="#include <sys/mman.h>"/>
<node CREATED="1341286503650" ID="ID_1583422332" MODIFIED="1341286503650" TEXT="int munmap(caddr_t addr, size_t len);"/>
<node CREATED="1341286518429" ID="ID_1312469547" MODIFIED="1341286520066" TEXT="Returns: 0 if OK, -1 on error "/>
<node CREATED="1341286530856" ID="ID_920248923" MODIFIED="1341286546843" TEXT="A memory mapped region is automatically unmapped when the process terminates, or by calling munmap directly. Closing the file descriptor filedes does hot unmap the region. "/>
<node CREATED="1341292519107" ID="ID_563840572" MODIFIED="1341292562196" TEXT="munmap does not affect the object that was mapped,that is, the call to munmap does not cause the contents of the mapped region to be written to the disk file. The updating of the disk file for a MAP_SHARED region happens automatically by the kernel's virtual memory algorithm as we store into the memory mapped region. "/>
</node>
<node CREATED="1341293077169" ID="ID_1720311487" MODIFIED="1341293079433" TEXT="msync">
<node CREATED="1341293096019" ID="ID_284263614" MODIFIED="1341293099056" TEXT="#include <sys/types.h>"/>
<node CREATED="1341293096019" ID="ID_547716544" MODIFIED="1341293099087" TEXT="#include <sys/mman.h>"/>
<node CREATED="1341293081382" ID="ID_975816871" MODIFIED="1341293081382" TEXT="int msync(void *start, size_t length, int flags);">
<node CREATED="1341293149220" ID="ID_51874461" MODIFIED="1341293154337" TEXT="MS_ASYNC"/>
<node CREATED="1341293155341" ID="ID_518465068" MODIFIED="1341293169945" TEXT="MS_SYNC"/>
<node CREATED="1341293170949" ID="ID_1944948368" MODIFIED="1341293172636" TEXT="MS_INVALIDATE"/>
</node>
<node CREATED="1341293196367" ID="ID_151402877" MODIFIED="1341293199005" TEXT="Returns: 0 if OK, -1 on error "/>
</node>
</node>
</node>
<node CREATED="1341293673913" FOLDED="true" ID="ID_1427592362" MODIFIED="1375431903532" POSITION="right" TEXT="IPC(InterProcess Communication)">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<node CREATED="1341295949046" ID="ID_182899331" MODIFIED="1374565411287" TEXT="System V IPC">
<node CREATED="1341296010736" FOLDED="true" ID="ID_1227441844" MODIFIED="1358084393839" TEXT="getXXX">
<node CREATED="1341300368793" ID="ID_1217472975" MODIFIED="1341300433666" TEXT="creates a new IPC structure or obtains a existed IPC structure"/>
<node CREATED="1341300399147" ID="ID_14596799" MODIFIED="1341300568610" TEXT="specifies key to get a IPC structure identifer ">
<node CREATED="1341300708577" ID="ID_872224181" MODIFIED="1341300719479" TEXT="same key,same identifier"/>
<node CREATED="1341300719793" ID="ID_952146000" MODIFIED="1341300818968" TEXT="a IPC structure has a unique identifier"/>
</node>
<node CREATED="1341300585954" ID="ID_870157002" MODIFIED="1341300588182" TEXT="key">
<node CREATED="1341300614289" ID="ID_1276116549" MODIFIED="1341300614289" TEXT="IPC_PRIVATE">
<node CREATED="1341300626782" ID="ID_102072705" MODIFIED="1341300651360" TEXT="always creates new IPC structure"/>
<node CREATED="1341300657359" ID="ID_61752347" MODIFIED="1341300701815" TEXT="server stores identifer in file system,client fetchs it"/>
</node>
</node>
<node CREATED="1341300588449" ID="ID_315654963" MODIFIED="1341300596208" TEXT="flag">
<node CREATED="1341300861022" ID="ID_818373656" MODIFIED="1341300869272" TEXT="IPC_CREAT"/>
<node CREATED="1341300870026" ID="ID_758367544" MODIFIED="1341300875499" TEXT="IPC_EXCL"/>
</node>
</node>
<node CREATED="1341294978187" ID="ID_1947676420" MODIFIED="1341301682765" TEXT="//#include<sys/ipc.h>
struct ipc_perm {
 key_t key; /* Key supplied to shmget(2) */
 uid_t uid; /* Effective UID of owner */
 gid_t gid; /* Effective GID of owner */
 uid_t cuid; /* Effective UID of creator */
 gid_t cgid; /* Effective GID of creator */
 unsigned short mode; /* Permissions + SHM_DEST
 and SHM_LOCKED flags */ 
 unsigned short seq; /* Sequence number */ 
 };">
<node CREATED="1341301689679" ID="ID_1482105925" MODIFIED="1341301693842" TEXT="mode">
<node CREATED="1341301724955" ID="ID_605630701" MODIFIED="1341301732713" TEXT="message queue"/>
<node CREATED="1341301733006" ID="ID_887119230" MODIFIED="1341301749046" TEXT="semaphore"/>
<node CREATED="1341301750279" ID="ID_1009924503" MODIFIED="1341301765414" TEXT="shared memory">
<node CREATED="1341301821998" ID="ID_235064886" MODIFIED="1341301832933" TEXT="user-read">
<node CREATED="1341301862010" ID="ID_1268183027" MODIFIED="1341301867206" TEXT="SHM_R"/>
</node>
<node CREATED="1341301833187" ID="ID_1897624536" MODIFIED="1341301838466" TEXT="user-write">
<node CREATED="1341301873622" ID="ID_1704187216" MODIFIED="1341301876615" TEXT="SHM_W"/>
</node>
<node CREATED="1341301838703" ID="ID_198621206" MODIFIED="1341301843202" TEXT="group-read">
<node CREATED="1341301883565" ID="ID_1901909274" MODIFIED="1341301892624" TEXT="SHM_R>>3"/>
</node>
<node CREATED="1341301843434" ID="ID_421973819" MODIFIED="1341301847757" TEXT="group-write">
<node CREATED="1341301895105" ID="ID_1297924" MODIFIED="1341301903846" TEXT="SHM_W>>3"/>
</node>
<node CREATED="1341301847950" ID="ID_352316684" MODIFIED="1341301850954" TEXT="other-read">
<node CREATED="1341301905998" ID="ID_421370008" MODIFIED="1341301911347" TEXT="SHM_R>>6"/>
</node>
<node CREATED="1341301851187" ID="ID_1713404653" MODIFIED="1341301856594" TEXT="other-write">
<node CREATED="1341301929294" ID="ID_1470757791" MODIFIED="1341301934169" TEXT="SHM_W>>6"/>
</node>
</node>
</node>
</node>
<node CREATED="1341299854336" ID="ID_1310268124" MODIFIED="1341301976004" TEXT="configuration limits">
<node CREATED="1341302017327" ID="ID_984069510" MODIFIED="1341302025520" TEXT="/etc/conf/cf. d/mtune"/>
</node>
<node CREATED="1341293727522" FOLDED="true" ID="ID_712599293" MODIFIED="1374570580757" TEXT="shared memory">
<icon BUILTIN="full-1"/>
<node CREATED="1341294866748" ID="ID_478450725" MODIFIED="1341295387283" TEXT="//#include<sys/shm.h>
struct shmid ds { 
 struct ipc_perm shm_perm; /* see Section 14.6.2 */ 
 struct anon_map *shm_amp; /* pointer in kernel */ 
 int shm_segsz; /* size of segment in bytes */ 
 ushort shm_Ikcnt; /* number of times segment is being locked */ 
 pid_t shm_Ipid; /* pid of last shmop() */ 
 pid_t shm_cpid; /* pid of creator */ 
 ulong shm_nattch; /* number of current attaches */ 
 ulong shm_cnattch; /* used only for shminfo */ 
 time_t shm_atime; /* last-attach time */ 
 time_t shm_dtime; /* last-detach time */ 
 time_t shm_ctime; /* last-change time */ 
 }; "/>
<node CREATED="1341295175167" FOLDED="true" ID="ID_972102095" MODIFIED="1374570578573" STYLE="fork" TEXT="system limits that affect shared memory ">
<node CREATED="1341302113240" ID="ID_1349606693" MODIFIED="1374565468274" TEXT="SHMALL System wide maximum of shared memory pages.(Linux /proc/sys/kernel/shmall)"/>
<node CREATED="1341295208607" ID="ID_1788937460" MODIFIED="1374565468274" TEXT="SHMMAX The maximum size in bytes of a shared memory segment. (Linux /proc/sys/kernel/shmmax)"/>
<node CREATED="1341295208607" ID="ID_415212494" MODIFIED="1374565468274" TEXT="SHMMIN The minimum size in bytes of a shared memory segment. 1"/>
<node CREATED="1341295208607" ID="ID_1069350097" MODIFIED="1374565468274" TEXT="SHMMNI The maximum number of shared memory segments, systemwide. (Linux /proc/sys/kernel/shmmni)"/>
<node CREATED="1341295208607" ID="ID_294674934" MODIFIED="1374565468274" TEXT="SHMSEG The maximum number of shared memory segments, per process. 6"/>
</node>
<node CREATED="1341295458763" FOLDED="true" ID="ID_1819317811" MODIFIED="1374570574486" TEXT="shmget">
<node CREATED="1341295474175" ID="ID_751004884" MODIFIED="1341295474175" TEXT="#include <sys/types.h>"/>
<node CREATED="1341295474175" ID="ID_176169853" MODIFIED="1341295474175" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341295474175" ID="ID_997293325" MODIFIED="1341295474175" TEXT="#include <sys/shm.h>"/>
<node CREATED="1341295474175" ID="ID_1596773694" MODIFIED="1341295484146" TEXT="int shmget (key_t key, int size,int flag) ;"/>
<node CREATED="1341295474175" ID="ID_449376456" MODIFIED="1341295474175" TEXT="Returns: shared memory ID if OK, -1 on error"/>
</node>
<node CREATED="1341302420834" ID="ID_865926474" MODIFIED="1374570565906" TEXT="shmctl">
<node CREATED="1341302434595" ID="ID_345207944" MODIFIED="1341302434595" TEXT="#include <sys/types.h>"/>
<node CREATED="1341302434596" ID="ID_796659825" MODIFIED="1341302434596" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341302434597" ID="ID_600334220" MODIFIED="1341302434597" TEXT="#include <sys/shm.h>"/>
<node CREATED="1341302434598" FOLDED="true" ID="ID_1988080660" MODIFIED="1374570572193" TEXT="int shmctl(int shmid, int cmd, struct shmid_ds *buf);">
<node CREATED="1341302440559" ID="ID_493226867" MODIFIED="1341302442657" TEXT="cmd">
<node CREATED="1341302444084" ID="ID_1395501179" MODIFIED="1341302518344" TEXT="IPC_STAT "/>
<node CREATED="1341302483525" ID="ID_364160896" MODIFIED="1341302521745" TEXT="IPC_SET "/>
<node CREATED="1341302656781" ID="ID_1330211640" MODIFIED="1341302658745" TEXT="IPC RMID "/>
<node CREATED="1341302499125" ID="ID_1652170653" MODIFIED="1341302537962" TEXT="SHM_LOCK "/>
<node CREATED="1341302509497" ID="ID_636642143" MODIFIED="1341302541799" TEXT="SHM_UNLOCK "/>
</node>
</node>
<node CREATED="1341302434599" ID="ID_1338359720" MODIFIED="1341302434599" TEXT="Returns: 0 if OK, -1 on error"/>
</node>
<node CREATED="1341302729185" ID="ID_1168344942" MODIFIED="1341302732106" TEXT="shmat">
<node CREATED="1341302744923" ID="ID_1688908816" MODIFIED="1341302744923" TEXT="#include <sys/types.h>"/>
<node CREATED="1341302744924" ID="ID_281880779" MODIFIED="1341302744924" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341302744925" ID="ID_536076557" MODIFIED="1341302744925" TEXT="#include <sys/shm.h>"/>
<node CREATED="1341302744926" ID="ID_1074944540" MODIFIED="1341302744926" TEXT="void *shmat(int shmid, void *addr, int flag);">
<node CREATED="1341302894721" ID="ID_213614112" MODIFIED="1341302898700" TEXT="flags">
<node CREATED="1341302900426" ID="ID_215492179" MODIFIED="1341302904353" TEXT="SHM_RND "/>
<node CREATED="1341302987708" ID="ID_29367939" MODIFIED="1341302989138" TEXT="SHM_RDONLY"/>
</node>
</node>
<node CREATED="1341302744927" ID="ID_1587618842" MODIFIED="1341302744927" TEXT="Returns: pointer to shared memory segment if OK, -1 on error"/>
</node>
<node CREATED="1341303325134" ID="ID_980075898" MODIFIED="1341303327836" TEXT="shmdt">
<node CREATED="1341303340260" ID="ID_340535876" MODIFIED="1341303340260" TEXT="#include <sys/types.h>"/>
<node CREATED="1341303340260" ID="ID_1505907721" MODIFIED="1341303340260" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341303340262" ID="ID_1326253363" MODIFIED="1341303340262" TEXT="#include <sys/shm.h>"/>
<node CREATED="1341303340262" ID="ID_1253895250" MODIFIED="1341303340262" TEXT="int shmdt(void *addr);"/>
<node CREATED="1341303340263" ID="ID_1251339769" MODIFIED="1341303340263" TEXT="Returns: 0 if OK, -1 on error"/>
</node>
</node>
<node CREATED="1341295960343" ID="ID_713621043" MODIFIED="1341296022321" TEXT="message queue">
<icon BUILTIN="full-2"/>
</node>
<node CREATED="1341295980417" ID="ID_507844474" MODIFIED="1374570586046" TEXT="semaphore set">
<icon BUILTIN="full-3"/>
<node CREATED="1341364975888" ID="ID_57600822" MODIFIED="1341365037658" TEXT="struct semid ds {
 struct ipc_perm semerm; /* see Section 14.6.2 */
 struct sem *sem_base; /* ptr to first semaphore in set */
 ushort sem_nsems; /* # of semaphores in set */
 time_t sem_otime; /* last-semop() time */
 time_t sem_ctime; /* last-change time */
 }; ">
<node CREATED="1341365075853" ID="ID_870194815" MODIFIED="1341397771103" TEXT="struct sem {
 ushort semval; /* semaphore value, always >= 0 */
 pid_t sempid; /* pid for last operation */
 ushort semncnt; /* # waiting for increase */
 ushort semzcnt; /* # waiting for zero */
 }; "/>
</node>
<node CREATED="1341365886675" ID="ID_665304680" MODIFIED="1341366898756" TEXT="system limits">
<node BACKGROUND_COLOR="#ccff66" CREATED="1341365917158" ID="ID_702256113" MODIFIED="1341366977377" TEXT="(Redhat Linux)
# man 5 proc
$cat /proc/sys/kernel/sem
250 32000 32 128
semmsl semmns semopm semmni
"/>
<node CREATED="1341366224807" FOLDED="true" ID="ID_604401426" MODIFIED="1341397693851" TEXT="semctl(semid,0, IPC_INFO(or SEM_INFO), struct seminfo*); ">
<node CREATED="1341366653671" ID="ID_479082150" MODIFIED="1341366890239" TEXT=" struct seminfo {
 int semmap; /* # of entries in semaphore map; unused */ 
 int semmni; /* Max. # of semaphore sets */ 
 int semmns; /* Max. # of semaphores in all semaphore sets */ 
 int semmnu; /* System-wide max. # of undo structures; unused */
 int semmsl; /* Max. # of semaphores in a set */ 
 int semopm; /* Max. # of operations for semop() */
 int semume; /* Max. # of undo entries per process; unused */
 int semusz; /* size of struct sem_undo */ 
 int semvmx; /* Maximum semaphore value */
 int semaem; /* Max. value that can be recorded for 
 semaphore adjustment (SEM_UNDO) */ 
 }; "/>
</node>
</node>
<node CREATED="1341314994157" FOLDED="true" ID="ID_1296062728" MODIFIED="1374565423689" TEXT="semget">
<node CREATED="1341364643507" ID="ID_257724758" MODIFIED="1341364686096" TEXT="create a new semaphore set or obtain a existed semphore set"/>
<node CREATED="1341393800623" ID="ID_797339531" MODIFIED="1341393800623" TEXT="#include <sys/types.h>"/>
<node CREATED="1341393800623" ID="ID_89102828" MODIFIED="1341393800623" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341393800623" ID="ID_1974005653" MODIFIED="1341393800623" TEXT="#include <sys/sem.h>"/>
<node CREATED="1341393800623" ID="ID_934005739" MODIFIED="1341393866478" TEXT="int semget (key_t key, int nsems,int flag) ;">
<node CREATED="1341393825573" ID="ID_169354451" MODIFIED="1341393881532" TEXT="creates a new semaphore set">
<node CREATED="1341393918900" ID="ID_1492989602" MODIFIED="1341394051502" TEXT="semget(key,nsems,IPC_CREAT| O_EXCL|access_permission)"/>
<node CREATED="1341394053053" ID="ID_1532587862" MODIFIED="1341394165952" TEXT="semget(IPC_PRIVATE,nsems,access_permission)"/>
</node>
<node CREATED="1341393842195" ID="ID_1720735928" MODIFIED="1341393885417" TEXT="obtains a existed semaphore set">
<node CREATED="1341394174054" ID="ID_1026980195" MODIFIED="1341394217892" TEXT="semget(key,0,0)"/>
</node>
</node>
<node CREATED="1341393800623" ID="ID_1553865104" MODIFIED="1341393800623" TEXT="Returns: sernaphore ID if OK, -1 on error"/>
</node>
<node CREATED="1341315009162" ID="ID_1125937381" MODIFIED="1358132624679" TEXT="semctl">
<node CREATED="1341364689128" ID="ID_1932316012" MODIFIED="1341364705073" TEXT="initialize semaphore set"/>
<node CREATED="1341364708620" ID="ID_585435116" MODIFIED="1341364743753" TEXT="creating and initializing is not atomic operation"/>
<node CREATED="1341367010096" ID="ID_23107852" MODIFIED="1341367028317" TEXT="#include <sys/types.h>"/>
<node CREATED="1341367030907" ID="ID_1843193242" MODIFIED="1341367044106" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341367045466" ID="ID_804977132" MODIFIED="1341367056015" TEXT="#include <sys/sem.h>"/>
<node CREATED="1341367057661" ID="ID_327562845" MODIFIED="1374570634164" TEXT="int semctl(int semid, int semnum, int cmd, union semunarg); ">
<node CREATED="1341367148720" ID="ID_1883786859" MODIFIED="1341367281167" TEXT="semnum ">
<node CREATED="1341367283457" ID="ID_763454522" MODIFIED="1341367283457" TEXT="semnum-th semaphore in set (starting at 0)"/>
</node>
<node BACKGROUND_COLOR="#ccff33" CREATED="1341366373249" ID="ID_1597305842" MODIFIED="1341367140930" TEXT="union semun {
 int val; /* Value for SETVAL */
 struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */
 unsigned short *array; /* Array for GETALL, SETALL */
 struct seminfo *__buf; /* Buffer for IPC_INFO (Linux specific) */
 }; "/>
<node CREATED="1341367257658" ID="ID_1315716304" MODIFIED="1341367260326" TEXT="cmd">
<node CREATED="1341394273138" ID="ID_777311892" MODIFIED="1374570615857" TEXT="IPC_STAT "/>
<node CREATED="1341394278340" ID="ID_1971383416" MODIFIED="1341394283522" TEXT="IPC_SET"/>
<node CREATED="1341394283824" ID="ID_1002626438" MODIFIED="1374570605140" TEXT="IPC_RMID "/>
<node CREATED="1341394350225" ID="ID_293792970" MODIFIED="1341394351506" TEXT="GETVAL "/>
<node CREATED="1341394351793" ID="ID_362762063" MODIFIED="1341394365648" TEXT="SETVAL "/>
<node CREATED="1341394386714" ID="ID_706786597" MODIFIED="1341394387964" TEXT="GETPID "/>
<node CREATED="1341394403570" ID="ID_1648181234" MODIFIED="1341394405178" TEXT="GETNCNT "/>
<node CREATED="1341394414763" ID="ID_645828013" MODIFIED="1341394416465" TEXT="GETZCNT "/>
<node CREATED="1341394427718" ID="ID_1881548970" MODIFIED="1341394428797" TEXT="GETALL "/>
<node CREATED="1341394429427" ID="ID_503292806" MODIFIED="1341394432361" TEXT="SETALL"/>
</node>
<node CREATED="1341394236805" ID="ID_1039607944" MODIFIED="1341394249911" TEXT="initialize semphore set">
<node CREATED="1341394530993" ID="ID_399566209" MODIFIED="1341394540891" TEXT="semctl(sem_id, n, SETVAL, init_value);"/>
</node>
</node>
</node>
<node CREATED="1341315013343" FOLDED="true" ID="ID_1804069828" MODIFIED="1358132609303" TEXT="semop">
<node CREATED="1341394556436" ID="ID_1082905639" MODIFIED="1341394556436" TEXT="#include <sys/types.h>"/>
<node CREATED="1341394556436" ID="ID_1410182787" MODIFIED="1341394556436" TEXT="#include <sys/ipc.h>"/>
<node CREATED="1341394556436" ID="ID_291465343" MODIFIED="1341394556436" TEXT="#include <sys/sem.h>"/>
<node CREATED="1341394556436" ID="ID_1483820110" MODIFIED="1341409259000" TEXT="int semop(int semid, struct sembuf semoparray[], size_t nops);">
<node CREATED="1341394563805" ID="ID_53565289" MODIFIED="1341394575460" TEXT="semoparray[]">
<node CREATED="1341394598008" ID="ID_669043662" MODIFIED="1341394630692" TEXT="struct sembuf {
 ushort sem_num; /* member # in set (0, 1 ..... nsems-l) */
 short sem_op; /* operation (negative, 0, or positive) */
 short sem_flg; /* IPC_NOWAIT, SEM_UNDO */
 }; ">
<node CREATED="1341397857065" ID="ID_1495944972" MODIFIED="1341397866068" TEXT="sem_op">
<node CREATED="1341397869131" ID="ID_1176180576" MODIFIED="1341408474341" TEXT="+">
<node CREATED="1341397884349" ID="ID_110424824" MODIFIED="1341398158787" TEXT="requires resources"/>
</node>
<node CREATED="1341397874225" ID="ID_1795673582" MODIFIED="1341409021461" TEXT="0">
<node CREATED="1341398088764" ID="ID_572037533" MODIFIED="1341398094366" TEXT="wait-for-zero"/>
</node>
<node CREATED="1341397876073" ID="ID_196491675" MODIFIED="1341409022261" TEXT="-">
<node CREATED="1341398107273" ID="ID_1372654629" MODIFIED="1341398166540" TEXT="release resources"/>
</node>
</node>
<node CREATED="1341398171257" ID="ID_273482510" MODIFIED="1341398176532" TEXT="sem_flg">
<node CREATED="1341398179049" ID="ID_435909430" MODIFIED="1341398185962" TEXT="IPC_NOWAIT">
<node CREATED="1341398188058" ID="ID_881107607" MODIFIED="1341409087398" TEXT="return with error immediately without waiting for resources become available .errno set to EAGAIN."/>
</node>
<node CREATED="1341398242042" ID="ID_89041707" MODIFIED="1341398250265" TEXT="SEM_UNDO"/>
</node>
</node>
</node>
</node>
<node CREATED="1341394556436" ID="ID_1157365318" MODIFIED="1341394556436" TEXT="Returns: 0 if OK, -1 on error"/>
<node CREATED="1341409125232" ID="ID_1431059437" MODIFIED="1342076349336" TEXT="errno">
<node CREATED="1341409135943" ID="ID_223950750" MODIFIED="1341409142119" TEXT="EAGAIN">
<node CREATED="1341409176026" ID="ID_544812252" MODIFIED="1341409289498" TEXT="sembuf.sem_flg set IPC_NOWAIT"/>
</node>
<node CREATED="1341409315974" FOLDED="true" ID="ID_1181048363" MODIFIED="1342076825980" TEXT="ERMID">
<node CREATED="1341409335255" ID="ID_409156259" MODIFIED="1341409398072" TEXT="semctl(semid,0,IPC_RMID,NULL)"/>
</node>
<node CREATED="1341409404457" ID="ID_1431990391" MODIFIED="1341409410769" TEXT="EINTR">
<node CREATED="1341409415546" ID="ID_1543440677" MODIFIED="1341409478182" TEXT="interrupted by signal"/>
</node>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1338637081684" FOLDED="true" ID="ID_969287546" MODIFIED="1375432086691" POSITION="right" TEXT="file & directory operations">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<node CREATED="1338647378283" ID="ID_1976735025" MODIFIED="1374567659255" TEXT="stat">
<node CREATED="1338647483842" ID="ID_68683273" MODIFIED="1338647519557" TEXT=":retrieve metadata of a file stored in inode"/>
<node CREATED="1338647522391" ID="ID_1982945353" MODIFIED="1338647537586" TEXT="utility">
<node CREATED="1338647539562" ID="ID_1486925285" MODIFIED="1338647541667" TEXT="stat"/>
</node>
<node CREATED="1338647543089" ID="ID_1890475945" MODIFIED="1338647547470" TEXT="function">
<node CREATED="1338647550066" ID="ID_1171455159" MODIFIED="1363164486295" TEXT="stat <sys/stat.h>">
<node CREATED="1338647597710" ID="ID_1694120859" MODIFIED="1338647597710" TEXT="int stat(const char *path, struct stat *buf);"/>
<node CREATED="1338647597711" ID="ID_1741831704" MODIFIED="1338647597711" TEXT="int fstat(int filedes, struct stat *buf);"/>
<node CREATED="1338647597711" ID="ID_1191552396" MODIFIED="1338647597711" TEXT="int lstat(const char *path, struct stat *buf);">
<node CREATED="1338647616133" ID="ID_1337029910" MODIFIED="1338647762177" TEXT="if path is symbol link, retrieve information of the link,
not the file referenced by link as stat do"/>
</node>
</node>
</node>
<node CREATED="1338647877239" ID="ID_1730061970" MODIFIED="1375432000903">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
struct stat {
</p>
<p>
              dev_t     st_dev;     /* ID of device containing file */
</p>
<p>
              ino_t     st_ino;     /* inode number */
</p>
<p>
              mode_t    st_mode;    /* file type & permission  */
</p>
<p>
              nlink_t   st_nlink;   /* number of hard links */
</p>
<p>
              uid_t     st_uid;     /* user ID of owner */
</p>
<p>
              gid_t     st_gid;     /* group ID of owner */
</p>
<p>
              dev_t     st_rdev;    /* device ID (if special file) */
</p>
<p>
              off_t     st_size;    /* total size, in bytes */
</p>
<p>
              blksize_t st_blksize; /* blocksize for filesystem I/O */
</p>
<p>
              blkcnt_t  st_blocks;  /* number of blocks allocated */
</p>
<p>
              time_t    st_atime;   /* time of last access */
</p>
<p>
              time_t    st_mtime;   /* time of last modification */
</p>
<p>
              time_t    st_ctime;   /* time of last status change */
</p>
<p>