COMP 3000 Essay 1 2010 Question 2

From Soma-notes
Revision as of 13:01, 13 October 2010 by Sblais2 (talk | contribs) (→‎Answer)
Jump to navigation Jump to search

Question

How do the available system calls in modern versions of the Linux Kernel (2.6.30+) compare with the system calls available in the earliest versions of UNIX? How has the system call interface been expanded, and why? Focus on major changes or extensions in functionality.

Answer

A system call is a mean by which programs in the user space can access kernel services. Systems calls vary from operating system to operating system, although the underlying concepts tends to be the same. In general, a process is not supposed to be able to access the kernel directly. It can'y access kernel memory and it can't call kernel functions. The CPU prevents this (called "protected mode"). System calls are an exception to this rule. For example, older x86 processors used an interrupt mechanism to go from user-space to kernel-space, but newer processor (PentiumII+) provided instructions that optimize this transition (using sysenter and sysexit instructions). All system calls are small programs built using the C programming language.

The Unix and Linux systems calls are roughly grouped into 6 categories: file management, device management, information maintenance, process control, communications and miscellaneous calls. The miscellaneous calls are all the ones that don’t really fit in the other categories, like system calls dealing with errors. Today, the Unix and Linux operating system contains hundreds of system calls but in general, they all came from the 35 system calls that came with one of the original UNIX OS in the early 70s. In the next paragraphs, we’re going to described the various system calls in each of the categories mentioned above, their evolution through history (major changes in functionality) and a comparison with the earliest versions of UNIX.

File Management Calls

The systems calls in this group deals with every type of operations that is required to run a file system in the operating system. Create file, delete file, opening a file and closing a file are just a sample of them and most of them hardly changed throughout the years.


chmod, chown and chdir has been available since the earliest UNIX and it is still used in today’s Linux kernels. The chmod and chown calls allows the users to change the file attributes and implements security to the file system. The system call chdir allows the process to change the current working directory. In the 4th distribution of UNIX from Berkeley (4BSD), new system calls where added to be able to give more control on the file system to the applications. The call chroot allows the process to change the current root directory with one specified in a path argument. fchmod and fchdir are the same as chmod and chdir except it takes file descriptors as arguments. As of Linux kernel 2.1.81, the chown system call follows symbolic link and introduce a new system call, lchown, that does not follow symbolic links. As of Linux 2.6.16, fchownat and fchmodat was added. It operates the same way as chown and chmod but takes more arguments to deal with relative pathnames.


Another three of the original UNIX system calls are open, creat and close. The open and creat calls allows processes to open and possibly create a file or device. Arguments flags are used to set either access modes, like O_RDONLY(read-only), to status flags, like O_APPEND(append mode). The only modifications made to the system calls were the addition of status flags where some of them are only linux-specific. The close call allows processes to close a file descriptor preventing it to be reused. No changes were made to it. As of Linux 2.6.16, openat was added. It for the same reasons as fchmodat and fchmownat.


The last two original UNIX system calls in this category are link and unlink. link creates a hard link to an existing file and unlink deletes a file link’s name and possibly the file it refers to. If the name refers to a symbolic link, only the link is removed. No major changes were done to the unlink system calls but new system calls were create from link. The symlink system call was added in 4.2BSD to allow the creation of symbolic links in the file system. Again in Linux 2.6.16, linkat and unlinkat were added for the same reasons as openat, fchmadat and fchownat.


The other system calls worth mentioning in this section are mkdir, rmdir and rename. These were added with 4.2BSD. mkdir allows the creation of a file directory and rmdir allows its deletion. Before 4.2BSD, to create and delete a directory, you would need to make a series of link and unlink system calls. The rename call allows to change the name or the location of a file. In Linux 2.6.16, mkdirat and renameat were added for the same reasons as linkat and unlinkat.

Device Management Calls

Information Maintenance Calls

Process Control Calls

Communications Calls

Miscellaneous System Calls

References

Here is the original manual --Lmundt 18:29, 7 October 2010 (UTC) http://cm.bell-labs.com/cm/cs/who/dmr/1stEdman.html

Linux Programmer's Manual, Linux man-pages project. http://www.kernel.org/doc/man-pages/