1. Introduction

    System Information

  2. Inter-Process Communication
  3. Signals

    Programming in Various Environments

  4. Script Programming
    1. Script Variables
    2. Test Conditions
    3. Control and Iteration
    4. Commonly used Programs
    5. Shell Capabilities
    6. Example looping script
    7. Example using Variables
    8. Example working with files
    9. Example install script
  5. C and C++ Programming
    1. POSIX System Capabilities
    2. More POSIX
    3. Threads
    4. Mutexes
    5. An example viewmod program
    6. An example serial program
  6. X Programming
  7. Debugging
  8. Credits

Introduction

Static Definition

Blocking Definition

A blocking function is one which will pause until the criteria of the function is met. A non-blocking function will perform the operation requested if possible, but will not wait until the function is possible to carry out. An example is the reading of a port. If a blocking instruction tries to read from a port and no data is available, it will wait or block. If data is available, it will perform the read. If a non-blocking instruction tries to read a port, if no data is available, it will normally return an error or status indicator and allow the program to continue.

This section will start with a description of the Portable Operating System Interface (POSIX). The reason for the POSIX standards is to make source code portable between various operating system platforms. The POSIX standards are produced by the Institute of Electrical and Electronics Engineers (IEEE). The standards are standardized by the International Organization for Standardization (ISO) and American National Standards Institute (ANSI).

POSIX Numbering

standardNew Document #ISO NumberDescription
POSIX.11003.1ISO 9945-1Basic Interfaces
POSIX.1a1003.1Extensions
POSIX.21003.1ISO Commands
POSIX.31003.1 Test methods
POSIX.41003.1b Real time
POSIX.4a1003.1c Threads
POSIX.4b1003.1d More Real time
POSIX.51003.1 ADA Binding
POSIX.61003.1e Security
POSIX.71003.1 System Administration
POSIX.81003.1f Network File Access
POSIX.91003.1 Fortran-77 Binding
POSIX.101003.1 Supercomputing
POSIX.121003.1g Sockets
POSIX.131003.1 Real Time Profiles
POSIX.151003.1 Batch/supercomputer extensions
POSIX.17IEEE 1224.2 Network Directory/name services

POSIX depends on:

  1. A compiler
  2. Headers usually in /usr/include
  3. Libraries
  4. An operating system that supports real time applications

POSIX Functionality

POSIX.1 Options

  • _POSIX_JOB_CONTROL - setpgid, tcgetgrp, tcsetpgrp
  • _POSIX_CHOWN_RESTRICTED - The ability to do a chown function is more restrictive
  • _POSIX_SAVED_IDS - A saved set-user-id and set-group-id are maintained by processes. Affects setgid, kill, fork, and setuid.
  • _POSIX_NO_TRUNC - Pathnames that are too long are not truncated but cause an error.
  • _POSIX_VDISABLE - Some special terminal characters can be disabled.
  • NGROUPS_MAX - Supplementary group IDs for each process can exist which may help determine file access permission.

POSIX.4 - The first item is required for POSIX.4 and the rest are options

  • Real time queued signals. SA_SIGINFO, SIGRTMIN, SIGRTMAX
  • _POSIX_REALTIME_SIGNALS - sigtimedwait, sigqueus, sigwaitinfo
  • _POSIX_PRIORITY_SCHEDULING - sched_getparam, sched_setparam, sched_getscheduler, sched_setscheduler, sched_rr_get_interval, sched_get_priority_min, sched_get_priority_max, sched_yield
  • _POSIX_TIMERS - clock_gettime, clock_settime, timer_gettime, timer_settime,clock_getres, timer_create, timer_delete, timer_getoverrun, nanosleep
  • _POSIX_ASYNCHRONOUS_IO - air_read, air_write, aio_error, aio_fsync, aio_cancel, aio_return, aio_suspend, lio_listio
  • _POSIX_PRIORITIZED_IO - Sets priorities for asynchronous I/O
  • _POSIX_SYNCHRONIZED_IO - If _POSIX_MAPPED_FILES (msync, fdatasync).
  • _POSIX_FSYNC - fsync
  • _POSIX_MAPPED_FILES - If _POSIX_SYNCHRONIZED_IO (mmap, munmap, msync, ftruncate)
  • _POSIX_MEMLOCK - mlockall, munlockall
  • _POSIX_MEMLOCK_RANGE - mlock, munlock
  • _POSIX_MEMORY_PROTECTION - mprotect
  • _POSIX_MESSAGE_PASSING - mq_getattr, mqset_attr, mq_open, mq_close, mq_notify, mq_send, mq_receive, mq_unlink
  • _POSIX_SEMAPHORES - sem_close, sem_destroy, sem_init, sem_open, sem_trywait, sem_unlink, sem_wait, sem_getvalue, sem_post.
  • _POSIX_SHARED_MEMORY_OBJECTS - mmap, munmap, sbm_close, sbm_open, ftruncate, sbm_unlink.

The line:

#define _POSIX_SOURCE

Indicates that the program is POSIX.1 compliant, the 1990 version of POSIX. The line:

#define _POSIX_C_SOURCE 199309

Indicates the program is POSIX.4 compliant. These lines mean only POSIX functions and symbols are used.