babu madhav institute of information technology, utu -...

12
Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 1 of 12 Babu Madhav Institute of Information Technology, UTU - 2016 5 Years Integrated M.Sc.(IT) Semester 6 Practical List 060010601 UNIX Internals Practical No. 1 Enrollment No. Practical Problem Write a program to implement cat command using command line argument and Implement program with taking different buffer size. i.e. 1 byte, 512 byte, 1024 byte and maximum available size of buffer. Objective(s) Student shall be able to perform low level file accessing operations and buffering mechanism. Pre-requisite System calls used to access file, buffered I/O, knowledge of cat command Duration for completion 2 hours. PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems. PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development. CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management. Solution must contain Programs code, test data and conclusion Nature of submission Handwritten References for solving the problem 1. The Design of the UNIX OS, M. J. Batch Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das Tata McGraw Post Laboratory questions 1. List name of system call used in file access. 2. Which are different file access modes in open() system call? 3. Give syntax of read() system call. 4. What is the return value of read() system call? 5. Does consecutive read() system call always performs disk read operation? Why? Assessment Solution achieves the desired objective(s) Viva Out of Marks 10 05 Secured by the Student Signature Date

Upload: truongcong

Post on 14-May-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 1 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

5 Years Integrated M.Sc.(IT) – Semester 6 Practical List

060010601 – UNIX Internals

Practical No. 1 Enrollment No.

Practical Problem Write a program to implement cat command using command line argument and Implement program with taking different buffer size. i.e. 1 byte, 512 byte, 1024 byte and maximum available size of buffer.

Objective(s) Student shall be able to perform low level file accessing operations and buffering mechanism.

Pre-requisite System calls used to access file, buffered I/O, knowledge of cat command

Duration for completion 2 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code, test data and conclusion

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. List name of system call used in file access. 2. Which are different file access modes in open() system call? 3. Give syntax of read() system call. 4. What is the return value of read() system call? 5. Does consecutive read() system call always performs disk read operation? Why?

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 05

Secured by the Student

Signature

Date

Page 2: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 2 Enrollment No.

Practical Problem a) Write a program to implement cp command. Implement program with taking buffer size 1 byte, 512 byte, 1024 byte and maximum available size of buffer.

b) Extend above program to copy file only if it has content. c) Extend above program to accept one more command line argument as number say N.

Copy file only if content of file is greater than N bytes.

Objective(s) Student shall be able to perform low level file operation such as reading and writing.

Pre-requisite System calls used to access file, buffered I/O

Duration for completion 4 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code, test data and conclusion.

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What is the use of third argument in open() system call? 2. What is the return value of open() system call in case of success and in case of failure? 3. Give any two reasons for failure of open() system call? 4. When read system call returns 0? 5. Give syntax of write() system call? 6. What is the return value of write() system call? 7. Give any two reasons when write() system call fails? What it returns? 8. Write lseek() call to set pointer at the end of file. What it will return?

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 20 10

Secured by the Student

Signature

Date

Page 3: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 3 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 3 Enrollment No.

Practical Problem a) Write a command line program to count total number of vowels from the file. b) Write a command line program to print only odd line from the file. c) Write command line program to implement head, tail and wc command.

Note: write separate program for each command.

Objective(s) Student shall be able to perform file access as well as manipulate file current offset. Pre-requisite Knowledge of head, tail and wc utilities, lseek() system call

Duration for completion 4 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code, test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What do you mean by file’s current offset? 2. What is the return value of lseek() system call? Can it be negative, positive or zero? 3. What are the possible value for third argument in lseek() call? 4. Write a program to create a file with a hole in it. 5. Create program wc given in b. with the use of library functions. Compare the program

by execution timing with your program.

Assessment

Solution achieves the desired objective(s) Viva Out of Marks 20 5

Secured by the Student

Signature

Date

Page 4: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 4 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 4 Enrollment No.

Practical Problem a) Write a command line program to display file name and its INODE information in user readable form from given directory. Note: If directory is not provided in command line argument, display list from the current directory.[Do not display hidden files]

b) Write a program to implement ls -l command. Modify program to display type of file along with the name. Extend program to display list of file in sorted order of its type.

c) Write a program to display files of given file type in command line argument.

Objective(s) Student shall be able to perform access INODE information.

Pre-requisite Structure of directory and regular file, system calls to access file system.

Duration for completion 4 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code and test data Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What does directory consist of? 2. Which system call is used to access INODE information? 3. How many files can be associated with one INODE? How many INODEs can be

associated with one file? 4. What if a directory entry consist INODE number as 0?

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 5: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 5 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 5 Enrollment No.

Practical Problem a) Write a program to accept name of directory and file permission string as command line arguments. Change the permissions of all the files within the directory as per permission string given as command line argument. Permission string: consist of three character r,w and x for granting read, write and execute permission to current user. for revoking permission use -. for example: rwx = grant all permission to current user. rw- = grant read and write permission and revoke execute permission. r-- = grant read and revoke write and execute permissions.

b) Write a command line program to accept file name and display 1/4th content from the given file.

c) Write a program to display file name whose size is greater than 100 bytes from current directory.

Objective(s) Student shall be able to manipulate information of INODE.

Pre-requisite File permission in UNIX, and system calls related to access file system

Duration for completion 2 hours. PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry

problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What is st_mode mask? 2. List macros used to get information related to files with its perpose. 3. Which function is used to change the file permission? 4. What is a link? How many types of links can be created in UNIX? 5. What do you mean by sticky bit? 6. How do you get information about owner of the file? 7. List types of file in UNIX.

Assessment

Solution achieves the desired objective(s) Viva Out of Marks 20 5

Secured by the Student

Signature

Date

Page 6: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 6 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 6 Enrollment No.

Practical Problem a) Write a program to create a child process. Both processes will display id of each other.

b) Write a program to display process identifiers. Extend program to create a child process and again display process identifiers. Give your observation.

Objective(s) Student shall be able to create process and understand its environment. Pre-requisite Internal data structure used by kernel for open files.

Duration for completion 2 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO1: Introduce internal architecture of UNIX operating system. CO2: To understand file management.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. Name the data structure used by kernel to manage open files. 2. Define functions which are used to display process id and id of parent process. 3. When does fork() system call fail()? 4. What is zombie process? 5. Is child process id always higher value then parent process id? Justify.

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 7: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 7 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 7 Enrollment No.

Practical Problem Write a program to display “child process died” message on termination of one of its child process by parent process using signal. Child process will execute “ls” command before termination.[Perform ls command using exec system call]

Objective(s) Student shall be able to create process and understand process environment.

Pre-requisite Knowledge of process structure, Environment variables

Duration for completion 2 hours. PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry

problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: To understand process management and to study init and system boot process.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What is use of signal() system call? 2. What is the return value of fork() call? 3. Define kill() system call. 4. List out function for exec system call and write purpose of each function.

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 8: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 8 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 8 Enrollment No.

Practical Problem a) Write a program to create a child process. Parent process will display message “Child task completed” after termination of child process. (provide two to three different solutions)

b) Write a program to create a child process. Ensure termination of parent process before child process. The child process will display message “Parent terminated” after termination of it’s parent process. (provide two to three different solutions)

Objective(s) To understand process control.

Pre-requisite Knowledge of process structure in UNIX

Duration for completion 2 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: To understand process management and to study init and system boot process. CO4: To study IPC mechanism.

Solution must contain Programs code and test data Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. What is the use of wait() system call? 2. What is the purpose of WEXITSTATUS()? 3. What happens to orphan process? 4. What do you mean by zombie? 5. Give any two point of difference between wait() an waitpid()? 6. Which signal is delivered to parent process on termination of its child? 7. Give name of signal which can’t be handled or ignored.

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 9: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 9 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 9 Enrollment No.

Practical Problem a) Write a program to display content of file on console in child process. Parent process must wait for completion of child process.

b) Write a program to display message sent by child process in parent process.

Objective(s) Student shall be able to create process and understand process environment.

Pre-requisite Knowledge of process data structure

Duration for completion 2 hours. PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry

problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: To understand process management and to study init and system boot process.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. Name data structure used for managing process by UNIX kernel. 2. How can we close pipe? 3. What is use of pipe() system call? 4. What is return value of wait() system call? 5. Give importance of wait() system call.

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 10: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 10 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 10 Enrollment No.

Practical Problem Attempt any one a) Write a program to demonstrate communication between parent process to child

process via pipe. The parent process will pass the content of file to the child process. The child process displays content by converting upper case to lower case and lower case to upper.

b) Write a program to demonstrate communication between child process to the parent process via pipe. The child process will pass the content of file to the parent process. The parent process displays content into sentence case(i.e. capitalize first character of sentence).

Objective(s) To study IPC mechanism.

Pre-requisite Concept of pipe

Duration for completion 2 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO3: To understand process management and to study init and system boot process. CO4: To study IPC mechanism.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. Why pipe is known as anonymous pipe? 2. Give any two point of difference between named pipe and unnamed pipe. 3. Why communication using pipe is known as half duplex? 4. What happens to the processes if any one end of pipe is closed?

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 11: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 11 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 11 Enrollment No.

Practical Problem Write programs to implement reader/writer problem. The writer process will send the content of file to the reader process. The reader process will displays the content by capitalizing each word. (use named pipe concept)

Objective(s) To study IPC mechanism.

Pre-requisite Concept of named pipe

Duration for completion 2 hours. PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry

problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO4: To study IPC mechanism.

Solution must contain Programs code and test data

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. How one can create a named pipe via system call? 2. How process can open named pipe? 3. How to perform read and write in named pipe? 4. What happens to process which has read end of pipe and its write end is not open by

any other processes?

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date

Page 12: Babu Madhav Institute of Information Technology, UTU - …utu.ac.in/BMIIT/StudentCorner/sem6/PR_060010601.pdf · Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 2 of 12 Babu

Mr. Krunal Sukhwani, Mr. Hardik Vyas UNIX Internals Page 12 of 12

Babu Madhav Institute of Information Technology, UTU - 2016

Practical No. 12 Enrollment No.

Practical Problem Write programs to demonstrate communication between two or more processes via message queue mechanism.

Objective(s) To study IPC mechanism.

Pre-requisite Concept of System V IPC.

Duration for completion 3 hours.

PEO(s) to be achieved PEO2: To provide quality practical skill of tools and technologies to solve industry problems.

PO(s) to be achieved PO6: Ability to use the techniques, skills and modern tools as necessary for software development.

CO(s) to be achieved CO4: To study IPC mechanism.

Solution must contain Programs code

Nature of submission Handwritten

References for solving the problem

1. The Design of the UNIX OS, M. J. Batch – Prentice Hall 2. Advance Programming in the UNIX Environment, Stevens-PE. 3. UNIX System V.4 Concepts and Application, S. Das – Tata McGraw

Post Laboratory questions

1. List system call used for message queue, shared memory and semaphore? 2. How can you remove message queue? 3. What is the significant of IPC_CREAT? 4. Identify limits for each of the System V IPC mechanism.

Assessment

Solution achieves the desired objective(s) Viva

Out of Marks 10 5

Secured by the Student

Signature

Date