System Calls provide an interface to the services made available by Operating System.
Types of System Calls
- Process Control
- File Management
- Device Management
- Information Maintenance
- Communication
System Calls for Process Management
In UNIX, forking is the only mechanism to start a new process. The whole original process is precisely recreated, down to the registers and file descriptors. The original process and the copy (the parent and kid) part ways after the fork.
System Calls for File Management
Numerous system calls refer to the file system. The open command must first be used to open the file in order to read from or write to it. The file name to be opened is supplied together with a code of O_RDONLY, O_WRONLY, or O_RDWR, meaning open for reading, writing, or both, in either an absolute path name or relative to the working directory. To create a new file, use O_CREAT. The file descriptor that was returned can now be read from or written to. The file can then be closed by close in order to reuse the file descriptor on a later open.
The size, latest modification time, file mode (regular file, special file, directory, etc.), and other information are all recorded by UNIX. Programs can ask to see this data by using a stat system call.
System Calls for Directory Management
Instead of focusing solely on one particular file as we did in the previous section, we will examine certain system calls in this section that are more broadly applicable to directories or the entire file system. The first two calls, mkdir and rmdir, respectively create and delete empty directories. Link is the next call. Its goal is to enable the appearance of the same file under two or more names, frequently in distinct directories..
Miscellaneous System Calls
A variety of other system calls exist as well. We will look at just four of them here. The chdir call changes the current working directory. After the call
chdir("/usr/ast/test");
an open on the file xyz will open /usr/ast/test/xyz
.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.