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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [doc/] [posix.sgml] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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