SlideShare une entreprise Scribd logo
1  sur  16
UNIT -1  INTRODUCTION ,[object Object],[object Object],[object Object],[object Object]
Darshan,S.J.B.I.T The POSIX Feature  Test Macros ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],This features test macros are found in  <unistd.h>  header
Darshan,S.J.B.I.T The POSIX Feature  Test Macros 3. _POSIX_CHOWN_RESTRICTED:  If the defined value is  -1  ,users may change  Ownership of files owned by them . If the value is not -1 ,then only the users with special privileges may change the Ownership of nay files on a system.  If this constant is undefined in <unistd.h> header,user must use the  pathconf()   Or  fpathconf()  function. 4._POSIX_NO_TRUNC :  If the defined values is  -1  ,any long pathname  passed to an API is truncated to  _POSIX_NAME_MAX  bytes,otherwise any error  is generated. If this constant is undefined in <unistd.h> header,user must use the  pathconf()   Or  fpathconf()  function. 5._POSIX_VDISABLE:  If the defined value is  -1  ,then there is no  disabling character for special charactersfor all terminal devices files. If this constant is undefined in <unistd.h> header,user must use the  pathconf()   Or  fpathconf()  function.
Darshan,S.J.B.I.T Show test macros #define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L #include <iostream.h> #include <unistd.h> int main() { #ifdef  _POSIX_JOB_CONTROL cout<<“System supports job control”; #else cout<<“System does not support job control”; #endif . . . . }
Darshan,S.J.B.I.T Limits checking at compile time and at run time POSIX.1 & POSIX.1b define a set of system configuration limits in the form of  Constant in  <limits.h>  header. Compile time limit Value Meaning _POSIX_NGROUP_MAX 0 Maximum number of  supplement groups  to which a process may belong . _POSIX_TZNAME_MAX 3 Maximum number of characters in a  time zone name _ POSIX_CHILD_MAX 6 Maximum number of  child processes  that may created at any one time by a process _POSIX_LINK_MAX 8 Maximum number of  links  a file may have _ POSIX_STREAM_MAX 8 Maximum number of  I/O streams  that may be simultaneously by a process _ POSIX_NAME_MAX 14 Maximum number of  characters  allowed in a filename _POSIX_OPEN_MAX 16 Maximum number of  file  that may be opened simultaneously by a process _ POSIX_PATH_MAX 255 Maximum number of characters allowed in a  pathname _POSIX_MAX_INPUT 255 Maximum size in bytes of  terminal’s input queue _POSIX_MAX_CANON 255 Maximum size in bytes of  terminal’s canonical input queue _POSIX_ARG_MAX 4096 Maximum length of argument to the  exec  functions  including environment data. _ POSIX_SSIZE_MAX   32767 Maximum  value that can be stored in an object of type  ssize_t .
Darshan,S.J.B.I.T POSIX.1B CONSTANTS COMPILE TIME LIMIT VALUE MEANING _POSIX_AIO_MAX 1 The number of  simultaneously   asynchronous I/O  operations. _POSIX_AIO_LISTIO_MAX  2 The number of I/O operations that can be specified in a  list I/O call . _POSIX_MQ_OPEN_MAX  2 The number of  message queues  that can be open for a single process. _POSIX_MQ_PRIO_MAX  2 The maximum number of  message priorities  that can be assigned to messages _POSIX_RTSIG_MAX  8 The maximum  number of  realtime signal . _POSIX_TIMER_MAX   32 Maximum  number of timers  that can be used simultaneously  number of timers. _POSIX_SIGQUEUE_MAX  32 Maximum number of realtime signals that a process may queue at any one time _POSIX_DELAYTIMER_MAX  32 Maximum number of  overruns  allowed per timer. _POSIX_SEM_NSEMS_MAX  256 Maximum number of  semaphore s that may be used simultaneously per process _POSIX_SEM_VALUE_MAX 32767 The maximum  value a semaphore  may have
Darshan,S.J.B.I.T sysconf, pathconf & fpathconf To find out the  actual implemented configuration limit  system wide we can use  sysconf,pathconf & fpathconf The prototype of these functions are: #include<unistd.h> long sysconf ( const int  limit_name); long pathconf ( const char*  pathname, int  flimit_name); long fpathconf ( const   int  fdesc,int flimit_name); The  sysconf  is used to query general system configuration limits that are  implemented on a given system. The pathconf & fpathconf are used to query file-related configuration limits.
Darshan,S.J.B.I.T The possible limited value by the  sysconf  function Limit value sysconf return data _ SG_ARG_MAX Maximum length of argument to the  exec  functions  including environment data. _SC_AIO_LISTIO_MAX  The number of I/O operations that can be specified in a  list I/O call . _SC_AIO_MAX  The number of  simultaneously   asynchronous I/O  operations _SC_CHILD_MAX Maximum number of  child processes  that may created at any one time by a process _SC_CLK_TCK The number of clock ticks per second. _ SC_DELAYTIMER_MAX Maximum number of overruns allowed per timer _SC_JOB_CONTROL The POSIX_JOB_CONTROL value _SC_MQ_OPEN_MAX Maximum number of message queues per process _SC_MQ_PRIO_MAX Maximum priority value assignable to a message _SC_NGRUOP_MAX Maximum number of supplemental groups per process
Darshan,S.J.B.I.T The possible limited value by the  sysconf  function LIMIT VALUE sysconf return Data _SC_OPEN_MAX Maximum number of opened files per process _SC_RTSIG_MAX Maximum number of real time signals _SC_SAVED_IDS The _POSIX_SAVED_IDS value _ SC_SEM_NSEMS_MAX Maximum number of semaphores per process _SC_SIGQUEUE_MAX Maximum number of realtime signals that a process may queue at any one-time _SC_TIMERS The _POSIX_TIMERS Value _SC_VERSION The _POSIX_VERSION value.
Darshan,S.J.B.I.T The possible limited value by the  pathconf & fpathconf  function Limit value  pathconf/fathconf return Data _ PC_CHOWN_RESTRICTED The _POSIX_CHOWN_RESTRICTED value. _PC_LINK_MAX Maximum number of links a file may have _PC_MAX_CANON Maximum size in bytes of terminal canonical input queue _PC_MAX_INPUT Maximum size in bytes of terminal input queue _PC_NO_TRUNC The _POSIX_NO_TRUNC value _PC_NAME_MAX Maximum length in bytes of a file name. _PC_PATH_MAX Maximum length in bytes of a pathname _PC_PIPE_BUF Maximum size of a block of data that may be automatically read from or written to a pipe file _PC_VDISABLE The _POSIX_VDISABLE value
Darshan,S.J.B.I.T The POSIX.1 FIPS standard ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Darshan,S.J.B.I.T The X/Open Standards X/Open  organization was formed by a group of  European  companies to propose a common OS interface for their computing systems. XPG3 – 1989 XPG4 – 1994 COSE (Common Open software Environment)  formed in 1993 by  HP, IBM, Novell,  OSF and Sun Microsystems SPEC 1179 Incorporated in XPG4 as part of X/Open Common  Application Environment
Darshan,S.J.B.I.T Unix & POSIX API”S UNIX systems provides a set of application programming interface(API”S) functions  commonly known as  system calls  which may be called user’s programs to perform System specific functions. These fuctions allows user’s applications to directly to manipulate  system objects such as files and processes that  cannot be done by using standard  C library functions. Functions of API”S 1.Determine system configuration and user Infromation 2.File Manipulation 3.Process creation & control. 4.Interprocess communication 5.Network Communication
Darshan,S.J.B.I.T What happens when an API’s is called When an API’s is invoked by a process,then execution context is switched  by the kernel from a  usermode to a kernel mode User mode :  is the normal execution context of any user process. It allows the process to access its process-specific data only. Kernel mode :  Is a protective execution environment that allows a user to access kernels data in a restricted manner. In general ,calling an API is more time consuming than calling a user function due to  Context switching
Darshan,S.J.B.I.T API  COMMON CHARACTERISTICS POSIX & UNIX  API’s after performing the system functions returns an integer  value which indicates the termination status of the execution. If an API returns  -1  value,it means the API’s execution has failed,& global variable Declared in the  <errno.h>  header is set with an error code. A user process may call the  perror  function to print a message of the failure To the standard output.  or It may call the strerror function returns a message string & the user process may Print that message in its preferred way.
Darshan,S.J.B.I.T ERROR STATUS CODE ERROR STATUS CODE Meaning EACCESS A process doesn't have  access permission  to perform an operation via an API EAGAIN An API was aborted because some system resource it requested was temporarily unavailable. So the API should be called again later EBADF An API was called with an Invalid file descriptor ECHILD A process doesnot have any child process which it can wait on EFAULT An API was passed an invalid address in one of its argument EINTR An API execution was aborted due to signal Interruption EIO I/O error occurred in a API execution ENOENT An invalid filename was specified to an API ENOEXEC An AP Couldn't execute a program via of the exec API EPERM An API was aborted because the calling process doesn't have the superuser privilege EPIPE An API attempted to write data to a pipe which has no reader ENOMEM An API was aborted because it could allocate Dynamic memory

Contenu connexe

Tendances

Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
fefe7270
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
CODE BLUE
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
Moriyoshi Koizumi
 

Tendances (20)

Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
More on Lex
More on LexMore on Lex
More on Lex
 
Linux 系統程式--第一章 i/o 函式
Linux 系統程式--第一章 i/o 函式Linux 系統程式--第一章 i/o 函式
Linux 系統程式--第一章 i/o 函式
 
Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
 
Linker scripts
Linker scriptsLinker scripts
Linker scripts
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 
4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
Yapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed PerlYapcasia2011 - Hello Embed Perl
Yapcasia2011 - Hello Embed Perl
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
Biopython
BiopythonBiopython
Biopython
 
Console Io Operations
Console Io OperationsConsole Io Operations
Console Io Operations
 

En vedette

Unit 8
Unit 8Unit 8
Unit 8
siddr
 
Unit 7
Unit 7Unit 7
Unit 7
siddr
 
Question bank cn2
Question bank cn2Question bank cn2
Question bank cn2
sangusajjan
 

En vedette (20)

6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...6th Semester (June; July-2015) Computer Science and Information Science Engin...
6th Semester (June; July-2015) Computer Science and Information Science Engin...
 
Prog ii
Prog iiProg ii
Prog ii
 
Unit 8
Unit 8Unit 8
Unit 8
 
CEED Solved Paper
CEED  Solved PaperCEED  Solved Paper
CEED Solved Paper
 
NTFS and Inode
NTFS and InodeNTFS and Inode
NTFS and Inode
 
Unix processes
Unix processesUnix processes
Unix processes
 
Usp notes unit6-8
Usp notes unit6-8Usp notes unit6-8
Usp notes unit6-8
 
Unit 7
Unit 7Unit 7
Unit 7
 
Unix kernal
Unix kernalUnix kernal
Unix kernal
 
Question bank cn2
Question bank cn2Question bank cn2
Question bank cn2
 
Ch2
Ch2Ch2
Ch2
 
6th semester Computer Science and Information Science Engg (2013 December) Qu...
6th semester Computer Science and Information Science Engg (2013 December) Qu...6th semester Computer Science and Information Science Engg (2013 December) Qu...
6th semester Computer Science and Information Science Engg (2013 December) Qu...
 
IMM Module 2 - VTU MBA
IMM Module 2 - VTU MBAIMM Module 2 - VTU MBA
IMM Module 2 - VTU MBA
 
6th Semester CS / IS (2013-June) Question Papers
6th Semester CS / IS (2013-June) Question Papers6th Semester CS / IS (2013-June) Question Papers
6th Semester CS / IS (2013-June) Question Papers
 
Kernal
KernalKernal
Kernal
 
How inodes Work
How inodes WorkHow inodes Work
How inodes Work
 
VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...
VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...
VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...
 
System calls
System callsSystem calls
System calls
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 

Similaire à Unit 1

Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
Rohit Banga
 

Similaire à Unit 1 (20)

ipc.pptx
ipc.pptxipc.pptx
ipc.pptx
 
Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdf
 
linux installation.pdf
linux installation.pdflinux installation.pdf
linux installation.pdf
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
 
Mc7404 np final
Mc7404 np finalMc7404 np final
Mc7404 np final
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
Operating system concepts
Operating system conceptsOperating system concepts
Operating system concepts
 
Securing the tunnel with Raccoon
Securing the tunnel with RaccoonSecuring the tunnel with Raccoon
Securing the tunnel with Raccoon
 
Usp notes
Usp notesUsp notes
Usp notes
 
Os notes
Os notesOs notes
Os notes
 
Backtrack Manual Part6
Backtrack Manual Part6Backtrack Manual Part6
Backtrack Manual Part6
 
Lab 2_5
Lab 2_5Lab 2_5
Lab 2_5
 
MPI
MPIMPI
MPI
 
Linux : PSCI
Linux : PSCILinux : PSCI
Linux : PSCI
 
Project Jugaad
Project JugaadProject Jugaad
Project Jugaad
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
MPI
MPIMPI
MPI
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007
 

Unit 1

  • 1.
  • 2.
  • 3. Darshan,S.J.B.I.T The POSIX Feature Test Macros 3. _POSIX_CHOWN_RESTRICTED: If the defined value is -1 ,users may change Ownership of files owned by them . If the value is not -1 ,then only the users with special privileges may change the Ownership of nay files on a system. If this constant is undefined in <unistd.h> header,user must use the pathconf() Or fpathconf() function. 4._POSIX_NO_TRUNC : If the defined values is -1 ,any long pathname passed to an API is truncated to _POSIX_NAME_MAX bytes,otherwise any error is generated. If this constant is undefined in <unistd.h> header,user must use the pathconf() Or fpathconf() function. 5._POSIX_VDISABLE: If the defined value is -1 ,then there is no disabling character for special charactersfor all terminal devices files. If this constant is undefined in <unistd.h> header,user must use the pathconf() Or fpathconf() function.
  • 4. Darshan,S.J.B.I.T Show test macros #define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L #include <iostream.h> #include <unistd.h> int main() { #ifdef _POSIX_JOB_CONTROL cout<<“System supports job control”; #else cout<<“System does not support job control”; #endif . . . . }
  • 5. Darshan,S.J.B.I.T Limits checking at compile time and at run time POSIX.1 & POSIX.1b define a set of system configuration limits in the form of Constant in <limits.h> header. Compile time limit Value Meaning _POSIX_NGROUP_MAX 0 Maximum number of supplement groups to which a process may belong . _POSIX_TZNAME_MAX 3 Maximum number of characters in a time zone name _ POSIX_CHILD_MAX 6 Maximum number of child processes that may created at any one time by a process _POSIX_LINK_MAX 8 Maximum number of links a file may have _ POSIX_STREAM_MAX 8 Maximum number of I/O streams that may be simultaneously by a process _ POSIX_NAME_MAX 14 Maximum number of characters allowed in a filename _POSIX_OPEN_MAX 16 Maximum number of file that may be opened simultaneously by a process _ POSIX_PATH_MAX 255 Maximum number of characters allowed in a pathname _POSIX_MAX_INPUT 255 Maximum size in bytes of terminal’s input queue _POSIX_MAX_CANON 255 Maximum size in bytes of terminal’s canonical input queue _POSIX_ARG_MAX 4096 Maximum length of argument to the exec functions including environment data. _ POSIX_SSIZE_MAX 32767 Maximum value that can be stored in an object of type ssize_t .
  • 6. Darshan,S.J.B.I.T POSIX.1B CONSTANTS COMPILE TIME LIMIT VALUE MEANING _POSIX_AIO_MAX 1 The number of simultaneously asynchronous I/O operations. _POSIX_AIO_LISTIO_MAX 2 The number of I/O operations that can be specified in a list I/O call . _POSIX_MQ_OPEN_MAX 2 The number of message queues that can be open for a single process. _POSIX_MQ_PRIO_MAX 2 The maximum number of message priorities that can be assigned to messages _POSIX_RTSIG_MAX 8 The maximum number of realtime signal . _POSIX_TIMER_MAX 32 Maximum number of timers that can be used simultaneously number of timers. _POSIX_SIGQUEUE_MAX 32 Maximum number of realtime signals that a process may queue at any one time _POSIX_DELAYTIMER_MAX 32 Maximum number of overruns allowed per timer. _POSIX_SEM_NSEMS_MAX 256 Maximum number of semaphore s that may be used simultaneously per process _POSIX_SEM_VALUE_MAX 32767 The maximum value a semaphore may have
  • 7. Darshan,S.J.B.I.T sysconf, pathconf & fpathconf To find out the actual implemented configuration limit system wide we can use sysconf,pathconf & fpathconf The prototype of these functions are: #include<unistd.h> long sysconf ( const int limit_name); long pathconf ( const char* pathname, int flimit_name); long fpathconf ( const int fdesc,int flimit_name); The sysconf is used to query general system configuration limits that are implemented on a given system. The pathconf & fpathconf are used to query file-related configuration limits.
  • 8. Darshan,S.J.B.I.T The possible limited value by the sysconf function Limit value sysconf return data _ SG_ARG_MAX Maximum length of argument to the exec functions including environment data. _SC_AIO_LISTIO_MAX The number of I/O operations that can be specified in a list I/O call . _SC_AIO_MAX The number of simultaneously asynchronous I/O operations _SC_CHILD_MAX Maximum number of child processes that may created at any one time by a process _SC_CLK_TCK The number of clock ticks per second. _ SC_DELAYTIMER_MAX Maximum number of overruns allowed per timer _SC_JOB_CONTROL The POSIX_JOB_CONTROL value _SC_MQ_OPEN_MAX Maximum number of message queues per process _SC_MQ_PRIO_MAX Maximum priority value assignable to a message _SC_NGRUOP_MAX Maximum number of supplemental groups per process
  • 9. Darshan,S.J.B.I.T The possible limited value by the sysconf function LIMIT VALUE sysconf return Data _SC_OPEN_MAX Maximum number of opened files per process _SC_RTSIG_MAX Maximum number of real time signals _SC_SAVED_IDS The _POSIX_SAVED_IDS value _ SC_SEM_NSEMS_MAX Maximum number of semaphores per process _SC_SIGQUEUE_MAX Maximum number of realtime signals that a process may queue at any one-time _SC_TIMERS The _POSIX_TIMERS Value _SC_VERSION The _POSIX_VERSION value.
  • 10. Darshan,S.J.B.I.T The possible limited value by the pathconf & fpathconf function Limit value pathconf/fathconf return Data _ PC_CHOWN_RESTRICTED The _POSIX_CHOWN_RESTRICTED value. _PC_LINK_MAX Maximum number of links a file may have _PC_MAX_CANON Maximum size in bytes of terminal canonical input queue _PC_MAX_INPUT Maximum size in bytes of terminal input queue _PC_NO_TRUNC The _POSIX_NO_TRUNC value _PC_NAME_MAX Maximum length in bytes of a file name. _PC_PATH_MAX Maximum length in bytes of a pathname _PC_PIPE_BUF Maximum size of a block of data that may be automatically read from or written to a pipe file _PC_VDISABLE The _POSIX_VDISABLE value
  • 11.
  • 12. Darshan,S.J.B.I.T The X/Open Standards X/Open organization was formed by a group of European companies to propose a common OS interface for their computing systems. XPG3 – 1989 XPG4 – 1994 COSE (Common Open software Environment) formed in 1993 by HP, IBM, Novell, OSF and Sun Microsystems SPEC 1179 Incorporated in XPG4 as part of X/Open Common Application Environment
  • 13. Darshan,S.J.B.I.T Unix & POSIX API”S UNIX systems provides a set of application programming interface(API”S) functions commonly known as system calls which may be called user’s programs to perform System specific functions. These fuctions allows user’s applications to directly to manipulate system objects such as files and processes that cannot be done by using standard C library functions. Functions of API”S 1.Determine system configuration and user Infromation 2.File Manipulation 3.Process creation & control. 4.Interprocess communication 5.Network Communication
  • 14. Darshan,S.J.B.I.T What happens when an API’s is called When an API’s is invoked by a process,then execution context is switched by the kernel from a usermode to a kernel mode User mode : is the normal execution context of any user process. It allows the process to access its process-specific data only. Kernel mode : Is a protective execution environment that allows a user to access kernels data in a restricted manner. In general ,calling an API is more time consuming than calling a user function due to Context switching
  • 15. Darshan,S.J.B.I.T API COMMON CHARACTERISTICS POSIX & UNIX API’s after performing the system functions returns an integer value which indicates the termination status of the execution. If an API returns -1 value,it means the API’s execution has failed,& global variable Declared in the <errno.h> header is set with an error code. A user process may call the perror function to print a message of the failure To the standard output. or It may call the strerror function returns a message string & the user process may Print that message in its preferred way.
  • 16. Darshan,S.J.B.I.T ERROR STATUS CODE ERROR STATUS CODE Meaning EACCESS A process doesn't have access permission to perform an operation via an API EAGAIN An API was aborted because some system resource it requested was temporarily unavailable. So the API should be called again later EBADF An API was called with an Invalid file descriptor ECHILD A process doesnot have any child process which it can wait on EFAULT An API was passed an invalid address in one of its argument EINTR An API execution was aborted due to signal Interruption EIO I/O error occurred in a API execution ENOENT An invalid filename was specified to an API ENOEXEC An AP Couldn't execute a program via of the exec API EPERM An API was aborted because the calling process doesn't have the superuser privilege EPIPE An API attempted to write data to a pipe which has no reader ENOMEM An API was aborted because it could allocate Dynamic memory