OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [posix/] [v2_0/] [doc/] [posix.sgml] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
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
eCos POSIX compatibility layer
34
 
35
36
POSIX Standard Support
37
 
38
39
 
40
    
41
      eCos contains support for the POSIX Specification (ISO/IEC
42
      9945-1)[POSIX].
43
    
44
    
45
      POSIX support is divided between the POSIX and the FILEIO
46
      packages. The POSIX package provides support for threads,
47
      signals, synchronization, timers and message queues. The FILEIO
48
      package provides support for file and device I/O. The two
49
      packages may be used together or separately, depending on
50
      configuration.
51
    
52
    
53
      This document takes a functional approach to the POSIX
54
      library. Support for a function implies that the data types and
55
      definitions necessary to support that function, and the objects
56
      it manipulates, are also defined. Any exceptions to this are
57
      noted, and unless otherwise noted, implemented functions behave
58
      as specified in the POSIX standard.
59
    
60
    
61
      This document only covers the differences between the eCos
62
      implementation and the standard; it does not provide complete
63
      documentation. For full information, see the POSIX standard
64
      [POSIX]. Online, the Open Group Single Unix
65
      Specification [SUS2] provides complete documentation
66
      of a superset of POSIX. If you have access to a Unix system with
67
      POSIX compatibility, then the manual pages for this will be of
68
      use.  There are also a number of books available.
69
      [Lewine] covers the process, signal, file and I/O
70
      functions, while [Lewis1], [Lewis2],
71
      [Nichols] and [Norton] cover Pthreads and
72
      related topics (see Bibliography, xref). However, many of these
73
      books are oriented toward using POSIX in non-embedded systems,
74
      so care should be taken in applying them to programming under
75
      eCos.
76
    
77
    
78
      The remainder of this chapter broadly follows the structure
79
      of the POSIX Specification. References to the appropriate
80
      section of the Standard are included.
81
    
82
    
83
      Omitted functions marked with “// TBA”
84
      are potential candidates for later implementation.
85
    
86
 
87
88
89
 
90
91
Process Primitives [POSIX Section 3]
92
 
93
94
 
95
96
Functions Implemented
97
 
98
99
int kill(pid_t pid, int sig);
100
int pthread_kill(pthread_t thread, int sig);
101
int sigaction(int sig, const struct sigaction *act,
102
              struct sigaction *oact);
103
int sigqueue(pid_t pid, int sig, const union sigval value);
104
int sigprocmask(int how, const sigset_t *set,
105
                sigset_t *oset);
106
int pthread_sigmask(int how, const sigset_t *set,
107
                    sigset_t *oset);
108
int sigpending(sigset_t *set);
109
int sigsuspend(const sigset_t *set);
110
int sigwait(const sigset_t *set, int *sig);
111
int sigwaitinfo(const sigset_t *set, siginfo_t *info);
112
int sigtimedwait(const sigset_t *set, siginfo_t *info,
113
                 const struct timespec *timeout);
114
int sigemptyset(sigset_t *set);
115
int sigfillset(sigset_t *set);
116
int sigaddset(sigset_t *set, int signo);
117
int sigdelset(sigset_t *set, int signo);
118
int sigismember(const sigset_t *set, int signo);
119
unsigned int alarm( unsigned int seconds );
120
int pause( void );
121
unsigned int sleep( unsigned int seconds );
122
123
124
 
125
126
 
127
128
Functions Omitted
129
 
130
131
pid_t fork(void);
132
int execl( const char *path, const char *arg, ... );
133
int execv( const char *path, char *const argv[] );
134
int execle( const char *path, const char *arg, ... );
135
int execve( const char *path, char *const argv[],
136
            char *const envp[] );
137
int execlp( const char *path, const char *arg, ... );
138
int execvp( const char *path, char *const argv[] );
139
int pthread_atfork( void(*prepare)(void),
140
                    void (*parent)(void),
141
                    void (*child)() );
142
pid_t wait( int *stat_loc );
143
pid_t waitpid( pid_t pid, int *stat_loc,
144
               int options );
145
void _exit( int status );
146
147
148
 
149
150
 
151
152
Notes
153
154
  
155
    
156
    Signal handling may be enabled or disabled with the
157
    CYGPKG_POSIX_SIGNALS option. Since signals are used
158
    by other POSIX components, such as timers, disabling signals will
159
    disable those components too.
160
    
161
  
162
 
163
  
164
    
165
    kill() and
166
    sigqueue() may only take a
167
    pid argument of zero,
168
    which maps to the current process.
169
    
170
  
171
 
172
  
173
    
174
    The SIGEV_THREAD notification type is
175
            not currently implemented.
176
    
177
  
178
 
179
  
180
    
181
    Job Control and Memory Protection signals are
182
            not supported.
183
    
184
  
185
 
186
  
187
    
188
    An extra implementation defined
189
    si_code value,
190
    SI_EXCEPT, is defined to
191
    distinguish hardware generated exceptions from
192
    others.
193
    
194
  
195
 
196
  
197
    
198
    Extra signals are defined:
199
    _SIGTRAP_,_SIGIOT_,
200
    _SIGEMT_, and _SIGSYS_. These are
201
    largely to maintain compatibility with the signal numbers used by
202
    GDB.
203
    
204
  
205
 
206
  
207
    
208
    Signal delivery may currently occur at unexpected places in some
209
    API functions. Using longjmp() to transfer
210
    control out of a signal handler may result in the interrupted
211
    function not being able to complete properly. This may result in
212
    later function calls failing or deadlocking.
213
    
214
  
215
216
217
 
218
 
219
220
 
221
222
223
 
224
225
Process Environment [POSIX Section 4]
226
 
227
228
 
229
230
Functions Implemented
231
 
232
233
int uname( struct utsname *name );
234
time_t time( time_t *tloc );
235
char *getenv( const char *name );
236
int isatty( int fd );
237
long sysconf( int name );
238
239
240
 
241
242
 
243
244
Functions Omitted
245
246
pid_t getpid( void );
247
pid_t getppid( void );
248
uid_t getuid( void );
249
uid_t geteuid( void );
250
gid_t getgid( void );
251
gid_t getegid( void );
252
int setuid( uid_t uid );
253
int setgid( gid_t gid );
254
int getgroups( int gidsetsize, gid_t grouplist[] );
255
char *getlogin( void );
256
int getlogin_r( char *name, size_t namesize );
257
pid_t getpgrp( void );
258
pid_t setsid( void );
259
int setpgid( pid_t pid, pid_t pgid );
260
char *ctermid( char *s);
261
char *ttyname( int fd );                             // TBA
262
int ttyname_r( int fd, char *name, size_t namesize); // TBA
263
clock_t times( struct tms *buffer );                 // TBA
264
265
266
 
267
268
 
269
270
Notes
271
        
272
          
273
            The fields of the utsname
274
            structure are initialized as follows:
275
            
276
            sysname     “eCos”
277
            nodename    “”      (gethostname() is currently not available)
278
 
279
            release             Major version number of the kernel
280
            version             Minor version number of the kernel
281
            machine     “”      (Requires some config tool changes)
282
            
283
            
284
            
285
            The sizes of these strings are defined by
286
            CYG_POSIX_UTSNAME_LENGTH and
287
            CYG_POSIX_UTSNAME_NODENAME_LENGTH. The
288
            latter defaults to the value of the former, but may also
289
            be set independently to accommodate a longer node name.
290
            
291
          
292
 
293
          
294
            
295
            The time() function is currently
296
            implemented in the C library.
297
            
298
          
299
 
300
          
301
            A set of environment strings may be defined at configuration
302
            time with the CYGDAT_LIBC_DEFAULT_ENVIRONMENT
303
            option. The application may also define an environment by direct
304
            assignment to the environ
305
            variable.
306
            
307
          
308
 
309
          
310
            
311
            At present isatty() assumes that
312
            any character device is a tty and that all other devices are not
313
            ttys. Since the only kind of device that eCos currently supports
314
            is serial character devices, this is an adequate
315
            distinction.
316
            
317
          
318
 
319
          
320
            
321
            All system variables supported by sysconf will yield a
322
            value. However, those that are irrelevant to eCos will
323
            either return the default minimum defined in
324
            <limits.h>,
325
            or zero.
326
            
327
          
328
        
329
 
330
331
332
 
333
334
335
 
336
337
Files and Directories [POSIX Section 5]
338
 
339
340
 
341
342
Functions Implemented
343
 
344
345
DIR *opendir( const char *dirname );
346
struct dirent *readdir( DIR *dirp );
347
int readdir_r( DIR *dirp, struct dirent *entry,
348
               struct dirent **result );
349
void rewinddir( DIR *dirp );
350
int closedir( DIR *dirp );
351
int chdir( const char *path );
352
char *getcwd( char *buf, size_t size );
353
int open( const char * path , int oflag , ... );
354
int creat( const char * path, mode_t mode );
355
int link( const char *existing, const char *new );
356
int mkdir( const char *path, mode_t mode );
357
int unlink( const char *path );
358
int rmdir( const char *path );
359
int rename( const char *old, const char *new );
360
int stat( const char *path, struct stat *buf );
361
int fstat( int fd, struct stat *buf );
362
int access( const char *path, int amode );
363
long pathconf(const char *path, int name);
364
long fpathconf(int fd, int name);
365
366
367
 
368
369
 
370
371
Functions Omitted
372
 
373
374
mode_t umask( mode_t cmask );
375
int mkfifo( const char *path, mode_t mode );
376
int chmod( const char *path, mode_t mode );                     // TBA
377
int fchmod( int fd, mode_t mode );                              // TBA
378
int chown( const char *path, uid_t owner, gid_t group );
379
int utime( const char *path, const struct utimbuf *times );     // TBA
380
int ftruncate( int fd, off_t length );                          // TBA
381
382
383
 
384
385
 
386
387
Notes
388
 
389
        
390
          
391
            
392
            If a call to open() or creat() supplies
393
            the third _mode_ parameter, it will
394
            currently be ignored.
395
            
396
          
397
          
398
            
399
            Most of the functionality of these functions depends on
400
            the underlying filesystem.
401
            
402
            
403
          
404
            
405
            Currently access() only checks the
406
            F_OK mode explicitly, the others are
407
            all assumed to be true by default.
408
            
409
          
410
          
411
            
412
            The maximum number of open files allowed is supplied by
413
            the CYGNUM_FILEIO_NFILE option. The maximum number
414
            of file descriptors is supplied by the CYGNUM_FILEIO_NFD
415
            option.
416
            
417
          
418
        
419
420
421
 
422
423
424
 
425
426
Input and Output [POSIX Section 6]
427
 
428
429
 
430
431
Functions Implemented
432
 
433
434
int dup( int fd );
435
int dup2( int fd, int fd2 );
436
int close(int fd);
437
ssize_t read(int fd, void *buf, size_t nbyte);
438
ssize_t write(int fd, const void *buf, size_t nbyte);
439
int fcntl( int fd, int cmd, ... );
440
off_t lseek(int fd, off_t offset, int whence);
441
int fsync( int fd );
442
int fdatasync( int fd );
443
444
 
445
446
 
447
448
Functions Omitted
449
450
int pipe( int fildes[2] );
451
int aio_read( struct aiocb *aiocbp );                           // TBA
452
int aio_write( struct aiocb *aiocbp );                          // TBA
453
int lio_listio( int mode, struct aiocb *const list[],
454
                int nent, struct sigevent *sig);                // TBA
455
int aio_error( struct aiocb *aiocbp );                          // TBA
456
int aio_return( struct aiocb *aiocbp );                         // TBA
457
int aio_cancel( int fd, struct aiocb *aiocbp );                 // TBA
458
int aio_suspend( const struct aiocb *const list[],
459
                 int nent, const struct timespec *timeout );    // TBA
460
int aio_fsync( int op, struct aiocb *aiocbp );
461
// TBA
462
463
464
 
465
466
 
467
468
Notes
469
        
470
          
471
            
472
            Only the F_DUPFD command
473
            of fcntl() is currently implemented.
474
            
475
          
476
          
477
            
478
            Most of the functionality of these functions depends on
479
            the underlying filesystem.
480
            
481
          
482
        
483
484
485
 
486
487
488
 
489
490
Device and Class Specific Functions [POSIX Section 7]
491
 
492
493
 
494
495
Functions Implemented
496
497
speed_t cfgetospeed( const struct termios *termios_p );
498
int cfsetospeed( struct termios *termios_p, speed_t speed );
499
speed_t cfgetispeed( const struct termios *termios_p );
500
int cfsetispeed( struct termios *termios_p, speed_t speed );
501
int tcgetattr( int fd, struct termios *termios_p );
502
int tcsetattr( int fd, int optional_actions,
503
               const struct termios *termios_p );
504
int tcsendbreak( int fd, int duration );
505
int tcdrain( int fd );
506
int tcflush( int fd, int queue_selector );
507
int tcsendbreak( int fd, int action );
508
509
510
 
511
512
 
513
514
Functions Omitted
515
 
516
517
pid_t tcgetpgrp( int fd );
518
int tcsetpgrp( int fd, pid_t pgrp );
519
520
 
521
522
 
523
524
Notes
525
        
526
          
527
            
528
            Only the functionality relevant to basic serial device
529
            control is implemented. Only very limited support for
530
            canonical input is provided, and then only via the
531
            “tty” devices, not the “serial”
532
            devices. None of the functionality relevant to job
533
            control, controlling terminals and sessions is
534
            implemented.
535
            
536
          
537
          
538
            
539
            Only MIN = 0 and
540
            TIME = 0 functionality is
541
            provided.
542
            
543
          
544
          
545
            
546
            Hardware flow control is supported if the underlying
547
            device driver and serial port support it.
548
            
549
          
550
          
551
            
552
            Support for break, framing and parity errors depends on
553
            the functionality of the hardware and device driver.
554
            
555
          
556
        
557
558
559
 
560
561
562
 
563
564
C Language Services [POSIX Section 8]
565
 
566
567
 
568
569
Functions Implemented
570
571
char *setlocale( int category, const char *locale );
572
int fileno( FILE *stream );
573
FILE *fdopen( int fd, const char *type );
574
int getc_unlocked( FILE *stream);
575
int getchar_unlocked( void );
576
int putc_unlocked( FILE *stream );
577
int putchar_unlocked( void );
578
char *strtok_r( char *s, const char *sep,
579
                char **lasts );
580
char *asctime_r( const struct tm *tm, char *buf );
581
char *ctime_r( const time_t *clock, char *buf );
582
struct tm *gmtime_r( const time_t *clock,
583
                     struct tm *result );
584
struct tm *localtime_r( const time_t *clock,
585
                        struct tm *result );
586
int rand_r( unsigned int *seed );
587
588
589
 
590
591
 
592
593
Functions Omitted
594
595
void flockfile( FILE *file );
596
int ftrylockfile( FILE *file );
597
void funlockfile( FILE *file );
598
int sigsetjmp( sigjmp_buf env, int savemask );                  // TBA
599
void siglongjmp( sigjmp_buf env, int val );                     // TBA
600
void tzset(void);                                                       // TBA
601
602
603
 
604
605
 
606
607
Notes
608
        
609
          
610
            
611
            setlocale() is implemented in the C
612
            library Internationalization package.
613
            
614
          
615
          
616
            
617
            Functions fileno() and
618
            fdopen() are implemented in the C
619
            library STDIO package.
620
            
621
          
622
          
623
            
624
            Functions getc_unlocked(),
625
            getchar_unlocked(),
626
            putc_unlocked() and
627
            putchar_unlocked() are defined
628
            but are currently identical to their non-unlocked
629
            equivalents.
630
            
631
          
632
          
633
            
634
            strtok_r(), asctime_r(),
635
            ctime_r(), gmtime_r(),
636
            localtime_r() and
637
            rand_r() are all currently in
638
            the C library, alongside their non-reentrant versions.
639
            
640
          
641
        
642
643
644
 
645
646
647
 
648
649
System Databases [POSIX Section 9]
650
 
651
652
 
653
654
Functions Implemented
655
 
656
657
<none>
658
659
 
660
661
 
662
663
 
664
665
Functions Omitted
666
 
667
668
struct group *getgrgid( gid_t gid );
669
int getgrgid( gid_t gid, struct group *grp, char *buffer,
670
              size_t bufsize, struct group **result );
671
struct group *getgrname( const char *name );
672
int getgrname_r( const char *name, struct group *grp,
673
                 char *buffer, size_t bufsize, struct group **result );
674
struct passwd *getpwuid( uid_t uid );
675
int getpwuid_r( uid_t uid, struct passwd *pwd,
676
                char *buffer, size_t bufsize, struct passwd **result );
677
struct passwd *getpwnam( const char *name );
678
int getpwnam_r( const char *name, struct passwd *pwd,
679
                char *buffer, size_t bufsize, struct passwd **result );
680
681
682
 
683
684
 
685
686
Notes
687
        
688
          
689
            
690
            None of the functions in this section are implemented.
691
            
692
          
693
        
694
695
696
 
697
698
699
 
700
701
Data Interchange Format [POSIX Section 10]
702
 
703
704
This section details tar and
705
cpio formats. Neither of these is supported by
706
eCos.
707
708
709
 
710
711
712
 
713
714
Synchronization [POSIX Section 11]
715
 
716
 
717
718
 
719
720
Functions Implemented
721
 
722
723
int sem_init(sem_t *sem, int pshared, unsigned int value);
724
int sem_destroy(sem_t *sem);
725
int sem_wait(sem_t *sem);
726
int sem_trywait(sem_t *sem);
727
int sem_post(sem_t *sem);
728
int sem_getvalue(sem_t *sem, int *sval);
729
int pthread_mutexattr_init( pthread_mutexattr_t *attr);
730
int pthread_mutexattr_destroy( pthread_mutexattr_t *attr);
731
int pthread_mutex_init(pthread_mutex_t *mutex,
732
                       const pthread_mutexattr_t *mutex_attr);
733
int pthread_mutex_destroy(pthread_mutex_t *mutex);
734
int pthread_mutex_lock(pthread_mutex_t *mutex);
735
int pthread_mutex_trylock(pthread_mutex_t *mutex);
736
int pthread_mutex_unlock(pthread_mutex_t *mutex);
737
int pthread_condattr_init(pthread_condattr_t *attr);
738
int pthread_condattr_destroy(pthread_condattr_t *attr);
739
int pthread_cond_init(pthread_cond_t *cond,
740
                       const pthread_condattr_t *attr);
741
int pthread_cond_destroy(pthread_cond_t *cond);
742
int pthread_cond_signal(pthread_cond_t *cond);
743
int pthread_cond_broadcast(pthread_cond_t *cond);
744
int pthread_cond_wait(pthread_cond_t *cond,
745
                       pthread_mutex_t *mutex);
746
int pthread_cond_timedwait(pthread_cond_t *cond,
747
                           pthread_mutex_t *mutex,
748
                           const struct timespec *abstime);
749
750
751
 
752
753
 
754
755
Functions Omitted
756
 
757
758
sem_t *sem_open(const char *name, int oflag, ...);              // TBA
759
int sem_close(sem_t *sem);                                      // TBA
760
int sem_unlink(const char *name);                               // TBA
761
int pthread_mutexattr_getpshared( const pthread_mutexattr_t *attr,
762
                                  int *pshared );
763
int pthread_mutexattr_setpshared( const pthread_mutexattr_t *attr,
764
                                  int pshared );
765
int  pthread_condattr_getpshared( const pthread_condattr_t *attr,
766
                                  int *pshared);
767
int  pthread_condattr_setpshared( const pthread_condattr_t *attr,
768
                                  int pshared);
769
770
 
771
772
 
773
774
Notes
775
        
776
          
777
            
778
            The presence of semaphores is controlled by the
779
            CYGPKG_POSIX_SEMAPHORES option. This in turn
780
            causes the _POSIX_SEMAPHORES feature test
781
            macro to be defined and the semaphore API to be made
782
            available.
783
            
784
          
785
 
786
          
787
            
788
            The pshared argument to
789
            sem_init() is not implemented,
790
            its value is ignored.
791
            
792
          
793
 
794
          
795
            
796
            Functions sem_open(),
797
            sem_close() and
798
            sem_unlink() are present but
799
            always return an error (ENOSYS).
800
            
801
          
802
 
803
          
804
            
805
            The exact priority inversion protocols supported may be
806
            controlled with the
807
            _POSIX_THREAD_PRIO_INHERIT and
808
            _POSIX_THREAD_PRIO_PROTECT
809
            configuration options.
810
            
811
          
812
 
813
          
814
            
815
            {_POSIX_THREAD_PROCESS_SHARED} is
816
            not defined, so the
817
            process-shared mutex
818
            and condition variable attributes are not supported, and
819
            neither are the functions
820
            pthread_mutexattr_getpshared(),
821
            pthread_mutexattr_setpshared(),
822
            pthread_condattr_getpshared() and
823
            pthread_condattr_setpshared().
824
            
825
          
826
 
827
          
828
          
829
            Condition variables do not become bound to a particular
830
            mutex when
831
            pthread_cond_wait() is
832
            called. Hence different threads may wait on a condition
833
            variable with different mutexes. This is at variance with
834
            the standard, which requires a condition variable to
835
            become (dynamically) bound by the first waiter, and
836
            unbound when the last finishes. However, this difference
837
            is largely benign, and the cost of policing this feature
838
            is non-trivial.
839
          
840
        
841
        
842
843
844
 
845
846
847
 
848
849
Memory Management [POSIX Section 12]
850
 
851
852
 
853
854
Functions Implemented
855
 
856
857
<none>
858
859
860
 
861
862
 
863
864
Functions Omitted
865
 
866
867
int mlockall( int flags );
868
int munlockall( void );
869
int mlock( const void *addr, size_t len );
870
int munlock( const void *addr, size_t len );
871
void mmap( void *addr, size_t len, int prot, int flags,
872
           int fd, off_t off );
873
int munmap( void *addr, size_t len );
874
int mprotect( const void *addr, size_t len, int prot );
875
int msync( void *addr, size_t len, int flags );
876
int shm_open( const char *name, int oflag, mode_t mode );
877
int shm_unlink( const char *name );
878
879
880
 
881
882
 
883
884
Notes
885
886
None of these functions are currently provided. Some may
887
be implemented in a restricted form in the future.
888
889
 
890
891
892
 
893
894
895
 
896
897
Execution Scheduling [POSIX Section 13]
898
 
899
900
 
901
902
Functions Implemented
903
 
904
905
int sched_yield(void);
906
int sched_get_priority_max(int policy);
907
int sched_get_priority_min(int policy);
908
int sched_rr_get_interval(pid_t pid, struct timespec *t);
909
int pthread_attr_setscope(pthread_attr_t *attr, int scope);
910
int pthread_attr_getscope(const pthread_attr_t *attr, int *scope);
911
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit);
912
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit);
913
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
914
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
915
int pthread_attr_setschedparam( pthread_attr_t *attr, const struct sched_param *param);
916
int pthread_attr_getschedparam( const pthread_attr_t *attr,
917
                                struct sched_param *param);
918
int pthread_setschedparam(pthread_t thread, int policy,
919
                          const struct sched_param *param);
920
int pthread_getschedparam(pthread_t thread, int *policy,
921
                          struct sched_param *param);
922
int pthread_mutexattr_setprotocol( pthread_mutexattr_t *attr,
923
                                   int protocol);
924
int pthread_mutexattr_getprotocol( pthread_mutexattr_t *attr,
925
                                   int *protocol);
926
int pthread_mutexattr_setprioceiling( pthread_mutexattr_t *attr,
927
                                      int prioceiling);
928
int pthread_mutexattr_getprioceiling( pthread_mutexattr_t *attr,
929
                                      int *prioceiling);
930
int pthread_mutex_setprioceiling( pthread_mutex_t *mutex,
931
                                  int prioceiling,
932
                                  int *old_ceiling);
933
int pthread_mutex_getprioceiling( pthread_mutex_t *mutex,
934
                                  int *prioceiling);
935
936
937
 
938
939
 
940
941
Functions Omitted
942
 
943
944
int sched_setparam(pid_t pid, const struct sched_param *param);
945
int sched_getparam(pid_t pid, struct sched_param *param);
946
int sched_setscheduler(pid_t pid, int policy,
947
                       const struct sched_param *param);
948
int sched_getscheduler(pid_t pid);
949
950
951
 
952
953
 
954
955
Notes
956
        
957
        
958
          
959
          The functions sched_setparam(),
960
          sched_getparam(),
961
          sched_setscheduler() and
962
          sched_getscheduler() are present
963
          but always return an error.
964
          
965
        
966
        
967
          
968
          The scheduler policy SCHED_OTHER is
969
          equivalent to SCHED_RR.
970
          
971
        
972
        
973
          
974
          Only PTHREAD_SCOPE_SYSTEM
975
          is supported as a
976
          contentionscope
977
          attribute.
978
          
979
        
980
        
981
          
982
          The default thread scheduling attributes are:
983
          
984
          contentionscope          PTHREAD_SCOPE_SYSTEM
985
          inheritsched             PTHREAD_INHERIT_SCHED
986
          schedpolicy              SCHED_OTHER
987
          schedparam.sched         0
988
          
989
          
990
        
991
        
992
          
993
          Mutex priority inversion protection is controlled by a
994
          number of kernel configuration options.
995
          If CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT
996
          is defined then
997
          {_POSIX_THREAD_PRIO_INHERIT}
998
          will be defined and PTHREAD_PRIO_INHERIT may
999
          be set as the protocol in a
1000
          pthread_mutexattr_t
1001
          object.
1002
          If CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
1003
          is defined then
1004
          {_POSIX_THREAD_PRIO_PROTECT}
1005
          will be defined and PTHREAD_PRIO_PROTECT may
1006
          be set as the protocol in a
1007
          pthread_mutexattr_t object.
1008
          
1009
        
1010
        
1011
          
1012
          The default attribute values set by
1013
          pthread_mutexattr_init()
1014
          is to set the protocol attribute to
1015
          PTHREAD_PRIO_NONE and the prioceiling
1016
          attribute to zero.
1017
          
1018
        
1019
        
1020
 
1021
1022
1023
 
1024
1025
1026
 
1027
1028
Clocks and Timers [POSIX Section 14]
1029
 
1030
1031
 
1032
1033
Functions Implemented
1034
 
1035
1036
int clock_settime( clockid_t clock_id,
1037
const struct timespec *tp);
1038
int clock_gettime( clockid_t clock_id, struct timespec *tp);
1039
int clock_getres( clockid_t clock_id, struct timespec *tp);
1040
int timer_create( clockid_t clock_id, struct sigevent *evp,
1041
                  timer_t *timer_id);
1042
int timer_delete( timer_t timer_id );
1043
int timer_settime( timer_t timerid, int flags,
1044
                   const struct itimerspec *value,
1045
                   struct itimerspec *ovalue );
1046
int timer_gettime( timer_t timerid, struct itimerspec *value );
1047
int timer_getoverrun( timer_t timerid );
1048
int nanosleep( const struct timespec *rqtp, struct timespec *rmtp);
1049
1050
 
1051
1052
 
1053
 
1054
1055
 
1056
1057
Functions Omitted
1058
 
1059
1060
<none>
1061
1062
 
1063
1064
 
1065
1066
 
1067
1068
Notes
1069
 
1070
1071
  
1072
    
1073
    Currently timer_getoverrun() only
1074
    reports timer notifications that are delayed in the timer
1075
    subsystem.  If they are delayed in the signal subsystem, due to
1076
    signal masks for example, this is not counted as an overrun.
1077
    
1078
  
1079
 
1080
  
1081
    
1082
    The option CYGPKG_POSIX_TIMERS allows the timer support to be
1083
    enabled or disabled, and causes _POSIX_TIMERS to be defined
1084
    appropriately. This will cause other parts of the POSIX system to
1085
    have limited functionality.
1086
    
1087
  
1088
 
1089
1090
 
1091
1092
1093
 
1094
1095
1096
 
1097
1098
Message Passing [POSIX Section 15]
1099
 
1100
1101
 
1102
1103
Functions Implemented
1104
 
1105
1106
mqd_t mq_open( const char *name, int  oflag, ... );
1107
int mq_close( mqd_t  mqdes );
1108
int mq_unlink( const char *name );
1109
int mq_send( mqd_t mqdes, const char *msg_ptr,
1110
             size_t msg_len, unsigned int msg_prio );
1111
ssize_t mq_receive( mqd_t mqdes, char *msg_ptr,
1112
                    size_t msg_len, unsigned int *msg_prio );
1113
int mq_setattr( mqd_t mqdes, const struct mq_attr *mqstat,
1114
                struct mq_attr *omqstat );
1115
int mq_getattr( mqd_t mqdes, struct mq_attr *mqstat );
1116
int mq_notify( mqd_t mqdes, const struct sigevent *notification );
1117
1118
From POSIX 1003.1d draft: 
1119
1120
int mq_send( mqd_t mqdes, const char *msg_ptr,
1121
             size_t msg_len, unsigned int msg_prio,
1122
             const struct timespec *abs_timeout );
1123
ssize_t mq_receive( mqd_t mqdes, char *msg_ptr,
1124
                    size_t msg_len, unsigned int *msg_prio,
1125
             const struct timespec *abs_timeout );
1126
1127
1128
 
1129
1130
 
1131
1132
Functions Omitted
1133
 
1134
1135
<none>
1136
1137
 
1138
1139
 
1140
1141
 
1142
1143
Notes
1144
 
1145
1146
  
1147
    
1148
    The presence of message queues is controlled by the
1149
    CYGPKG_POSIX_MQUEUES option.  Setting this will
1150
    cause [_POSIX_MESSAGE_PASSING] to
1151
    be defined and the message queue API to be made available.
1152
    
1153
  
1154
 
1155
  
1156
    
1157
    Message queues are not currently filesystem objects. They live in
1158
    their own name and descriptor spaces.
1159
    
1160
  
1161
1162
 
1163
1164
1165
 
1166
1167
1168
 
1169
1170
Thread Management [POSIX Section 16]
1171
 
1172
1173
 
1174
1175
Functions Implemented
1176
 
1177
1178
int pthread_attr_init(pthread_attr_t *attr);
1179
int pthread_attr_destroy(pthread_attr_t *attr);
1180
int pthread_attr_setdetachstate(pthread_attr_t *attr,
1181
                                int detachstate);
1182
int pthread_attr_getdetachstate(const pthread_attr_t *attr,
1183
                                int *detachstate);
1184
int pthread_attr_setstackaddr(pthread_attr_t *attr,
1185
                              void *stackaddr);
1186
int pthread_attr_getstackaddr(const pthread_attr_t *attr,
1187
                              void **stackaddr);
1188
int pthread_attr_setstacksize(pthread_attr_t *attr,
1189
                              size_t stacksize);
1190
int pthread_attr_getstacksize(const pthread_attr_t *attr,
1191
                              size_t *stacksize);
1192
int pthread_create( pthread_t *thread,
1193
                    const pthread_attr_t *attr,
1194
                    void *(*start_routine)(void *),
1195
                    void *arg);
1196
pthread_t pthread_self( void );
1197
int pthread_equal(pthread_t thread1, pthread_t thread2);
1198
void pthread_exit(void *retval);
1199
int pthread_join(pthread_t thread, void **thread_return);
1200
int pthread_detach(pthread_t thread);
1201
int pthread_once(pthread_once_t *once_control,
1202
                 void (*init_routine)(void));
1203
1204
 
1205
1206
 
1207
1208
 
1209
1210
Functions Omitted
1211
 
1212
1213
<none>
1214
1215
 
1216
1217
 
1218
1219
 
1220
1221
Notes
1222
 
1223
1224
  
1225
    
1226
    The presence of thread support as a whole is controlled by the the
1227
    CYGPKG_POSIX_PTHREAD configuration option. Note that disabling
1228
    this will also disable many other features of the POSIX package,
1229
    since these are intimately bound up with the thread mechanism.
1230
    
1231
  
1232
 
1233
  
1234
    
1235
    The default (non-scheduling) thread attributes are:
1236
    
1237
    
1238
    detachstate            PTHREAD_CREATE_JOINABLE
1239
    stackaddr              unset
1240
    stacksize              unset
1241
    
1242
  
1243
 
1244
  
1245
    
1246
      Dynamic thread stack allocation is only provided if there is an
1247
      implementation of
1248
      malloc() configured (i.e. a package
1249
      implements the
1250
      CYGINT_MEMALLOC_MALLOC_ALLOCATORS
1251
      interface). If there is no malloc() available, then the thread
1252
      creator must supply a stack. If only a stack address is supplied
1253
      then the stack is assumed to be PTHREAD_STACK_MIN
1254
      bytes long. This size is seldom useful for any but the most
1255
      trivial of threads.  If a different sized stack is used, both
1256
      the stack address and stack size must be supplied.
1257
    
1258
  
1259
 
1260
  
1261
    
1262
      The value of PTHREAD_THREADS_MAX is supplied by
1263
      the CYGNUM_POSIX_PTHREAD_THREADS_MAX
1264
      option. This defines the maximum number of threads allowed. The
1265
      POSIX standard requires this value to be at least 64, and this
1266
      is the default value set.
1267
    
1268
  
1269
 
1270
  
1271
    
1272
    When the POSIX package is installed, the thread that calls
1273
    main() is initialized as a POSIX thread. The
1274
    priority of that thread is controlled by the
1275
    CYGNUM_POSIX_MAIN_DEFAULT_PRIORITY option.
1276
    
1277
  
1278
1279
 
1280
1281
1282
 
1283
1284
1285
 
1286
1287
Thread-Specific Data [POSIX Section 17]
1288
 
1289
1290
 
1291
1292
Functions Implemented
1293
 
1294
1295
int pthread_key_create(pthread_key_t *key,
1296
                       void (*destructor)(void *));
1297
int pthread_setspecific(pthread_key_t key, const void *pointer);
1298
void *pthread_getspecific(pthread_key_t key);
1299
int pthread_key_delete(pthread_key_t key);
1300
1301
 
1302
1303
 
1304
1305
 
1306
1307
Functions Omitted
1308
1309
<none>
1310
1311
1312
 
1313
1314
 
1315
1316
Notes
1317
 
1318
1319
  
1320
    
1321
    The value of PTHREAD_DESTRUCTOR_ITERATIONS is
1322
    provided by the
1323
    CYGNUM_POSIX_PTHREAD_DESTRUCTOR_ITERATIONS
1324
    option. This controls the number of times that a key destructor
1325
    will be called while the data item remains non-NULL.
1326
    
1327
  
1328
 
1329
  
1330
    
1331
    The value of PTHREAD_KEYS_MAX is provided
1332
    by the CYGNUM_POSIX_PTHREAD_KEYS_MAX
1333
    option. This defines the maximum number of per-thread data items
1334
    supported. The POSIX standard calls for this to be a minimum of
1335
    128, which is rather large for an embedded system. The default
1336
    value for this option is set to 128 for compatibility but it
1337
    should be reduced to a more usable value.
1338
    
1339
  
1340
1341
 
1342
1343
1344
 
1345
1346
1347
 
1348
1349
Thread Cancellation [POSIX Section 18]
1350
 
1351
1352
 
1353
1354
Functions Implemented
1355
 
1356
1357
int pthread_cancel(pthread_t thread);
1358
int pthread_setcancelstate(int state, int *oldstate);
1359
int pthread_setcanceltype(int type, int *oldtype);
1360
void pthread_testcancel(void);
1361
void pthread_cleanup_push( void (*routine)(void *),
1362
                           void *arg);
1363
void pthread_cleanup_pop( int execute);
1364
1365
1366
 
1367
 
1368
1369
 
1370
1371
Functions Omitted
1372
1373
<none>
1374
1375
1376
 
1377
1378
 
1379
1380
Notes
1381
1382
Asynchronous cancellation is only partially implemented.  In
1383
particular, cancellation may occur in unexpected places in some
1384
functions. It is strongly recommended that only synchronous
1385
cancellation be used.
1386
1387
1388
1389
 
1390
1391
1392
 
1393
1394
Non-POSIX Functions
1395
 
1396
1397
In addition to the standard POSIX functions defined above, the
1398
following non-POSIX functions are defined in the FILEIO package.
1399
1400
 
1401
1402
 
1403
1404
General I/O Functions
1405
1406
int ioctl( int fd, CYG_ADDRWORD com, CYG_ADDRWORD data );
1407
int select( int nfd, fd_set *in, fd_set *out, fd_set *ex, struct timeval *tv);
1408
1409
1410
 
1411
 
1412
1413
 
1414
1415
Socket Functions
1416
1417
int socket( int domain, int type, int protocol);
1418
int bind( int s, const struct sockaddr *sa, unsigned int len);
1419
int listen( int s, int len);
1420
int accept( int s, struct sockaddr *sa, socklen_t *addrlen);
1421
int connect( int s, const struct sockaddr *sa, socklen_t len);
1422
int getpeername( int s, struct sockaddr *sa, socklen_t *len);
1423
int getsockname( int s, struct sockaddr *sa, socklen_t *len);
1424
int setsockopt( int s, int level, int optname, const void *optval,
1425
                socklen_t optlen);
1426
int getsockopt( int s, int level, int optname, void *optval,
1427
                socklen_t *optlen);
1428
ssize_t recvmsg( int s, struct msghdr *msg, int flags);
1429
ssize_t recvfrom( int s, void *buf, size_t len, int flags,
1430
                  struct sockaddr *from, socklen_t *fromlen);
1431
ssize_t recv( int s, void *buf, size_t len, int flags);
1432
ssize_t sendmsg( int s, const struct msghdr *msg, int flags);
1433
ssize_t sendto( int s, const void *buf, size_t len, int flags,
1434
                const struct sockaddr *to, socklen_t tolen);
1435
ssize_t send( int s, const void *buf, size_t len, int flags);
1436
int shutdown( int s, int how);
1437
1438
1439
 
1440
1441
 
1442
1443
Notes
1444
1445
  
1446
   
1447
   The precise behaviour of these functions depends mainly on the
1448
   functionality of the underlying filesystem or network stack to
1449
   which they are applied.
1450
   
1451
  
1452
1453
1454
1455
 
1456
1457
 
1458
1459
 
1460
1461
 
1462
1463
References and Bibliography
1464
 
1465
    
1466
      [Lewine]
1467
      
1468
        Donald
1469
        A.
1470
        Lweine
1471
      
1472
      Posix Programmer’s Guide: Writing Portable Unix</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>1473</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>        Programs With the POSIX.1 Standard O’Reilly &</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>1474</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>        Associates; ISBN: 0937175730.
1475
 
1476
    
1477
      [Lewis1]
1478
      
1479
        Bil
1480
        Lewis
1481
      
1482
      
1483
        Daniel
1484
        J.
1485
        Berg
1486
      
1487
      Threads Primer: A Guide to Multithreaded Programming
1488
      Prentice Hall
1489
      ISBN: 013443698
1490
    
1491
 
1492
    
1493
      [Lewis2]
1494
      
1495
        Bil
1496
        Lewis
1497
      
1498
      
1499
        Daniel
1500
        J.
1501
        Berg
1502
      
1503
      Multithreaded Programming With Pthreads
1504
      
1505
        Prentice Hall Computer Books
1506
      
1507
      ISBN: 0136807291
1508
    
1509
 
1510
    
1511
      [Nichols]
1512
      
1513
        Bradford
1514
        Nichols
1515
      
1516
      
1517
        Dick
1518
        Buttlar
1519
      
1520
      
1521
        Jacqueline
1522
        Proulx
1523
        Farrell
1524
      
1525
      Pthreads Programming: A POSIX Standard for Better</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>1526</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>        Multiprocessing (O’Reilly Nutshell)
1527
      O’Reilly & Associates
1528
      
1529
      ISBN: 1565921151
1530
    
1531
 
1532
    
1533
      [Norton]
1534
      
1535
        Scott
1536
        J.
1537
        Norton
1538
      
1539
      
1540
        Mark
1541
        D.
1542
        Depasquale
1543
      
1544
      Thread Time: The MultiThreaded Programming Guide
1545
      Prentice Hall
1546
      
1547
      ISBN: 0131900676
1548
 
1549
 
1550
    
1551
      [POSIX]
1552
      Portable Operating System Interface(POSIX) -</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>1553</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>Part 1: System Application Programming Interface (API)[C</code></pre></td>
      </tr>
      <tr valign="middle">
         <td>1554</td>
         <td></td>
         <td></td>
         <td class="code"><pre><code>Language]
1555
      ISO/IEC 9945-1:1996, IEEE
1556
 
1557
    
1558
      [SUS2]
1559
      Open Group; Single Unix Specification, Version 2
1560
      
1561
      url="http://www.opengroup.org/public/pubs/online/7908799/index.html">http://www.opengroup.org/public/pubs/online/7908799/index.html
1562
    
1563
 
1564
  
1565
 
1566
1567
 
1568

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.