search instagram arrow-down

Archives

Categories

Meta

System Programming

System Call

System programming starts and ends with the system call. Syscalls are function invocation made from user space (Eg. your text editor, favorite game etc) into the kernel space (The core internal of the system) in order to request some service or resource from the operating system.
Linux implements far fewer system call than any other operating system. X86_64 Linux uses around 350 syscalls, while Microsoft Windows uses thousands of syscalls.

Kernel provides its services to the user space programs with a set of tightly defined entry points know as system calls. Program don’t make system call directly, they do so by thin wrapper routines in the standard library called Glibc.

#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
int main()
{
	int fd=open("/tmp/foo.txt",O_CREAT | O_WRONLY, 0600);
	if (fd<0){
		printf("There is error code: %d",errno);
		perror("foo");
	}
	write(fd,"My First System Program\n",24);
	close(fd);
}
Leave a Reply
Your email address will not be published. Required fields are marked *

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: