Anurag Group of Institutions

Total Page:16

File Type:pdf, Size:1020Kb

Anurag Group of Institutions

LINUX PROGRAMMING

HANDOUT ANURAG GROUP OF INSTITUTIONS DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING IV Yr CSE –I SEM (2012-2013) Linux Programming Time Table:

9:00- 9:50- 10:40- 11:30- 1:10- 2:00- 2:50- 9:50 10:40 11:30 12:20 2:00 2-50 3:40 MON TUE WED THR FRI SAT

Required Text Books:

 Unix System Programming using C++,T.Chan , PHI  Unix Concepts and Applications,4th edition, Sumitabha Das,TMH.  Beginning Linux Programming ,4th edition,N.Mathew,R.Stones,Wrox,Wiley India Edition.

Course Objectives:

 To provide the foundation of linux programming..  To understand the Linux utilities.  Be able to work with Bourne again shell(bash).  To provide exploration of file concepts.  To understand the process,role of kernel in process mangement,signal generation and handling .  Introduction to inter process communication,semaphores and multithreading.  To provide a general introduction to sockets.

Course Outcomes:

 Learn the utilities .  Able to develop shell programs.  Learn different API's(file,process etc.).  Be familiar with techniques for inter process communication.  Be familiar with socket programming Evaluation Methodology:

S.no Method of Evaluation Examination Dates Marks 1. Internal Exam -I 2. Internal Exam -II 3. Assignment -I 4. Assignment -II 5. External Exam

UNIT-I Syllabus: Linux Utilities: File handling utilities, Security by file permissions, Process utilities, Disk utilities, Networking commands, Filters, Text processing utilities and Backup utilities, sed- scripts, operation, addresses, commands, applications, awk-execution, fields and records, scripts, operation, patterns, actions, functions, using system commands in awk. Objectives:

 This unit provides an overview of Linux utilities.

 It focuses on the file handling utilities, text processing utilities and system commands.

Micro plan:

No. of Date S.No Topic lectures 1 File handling utilities 1 2 Security by file permissions 1 3 Process utilities 1 4 Disk utilities 1 5 Networking commands 1 6 Filters 1 7 Text processing utilities 1 8 Backup utilities 1 9 sed-scripts, operation, addresses, commands, applications 1 10 awk-execution, fields and records, scripts, operation 1 patterns, actions, functions, using system commands in 1 11 awk Total 11 Assignment: Q 1: Can we say that an absolute pathname is always longer than the corresponding relative pathname?

Q 2:Can a super user delete a file or directory of a user no matter how the permissions are set by the user?

Q 3: Explain different types of text handling utilities?

Q 4: Compare and contrast the cmp command and comm command.

Q 5: Does the awk command modify the original file?

UNIT-II Syllabus: Working with the Bourne again shell(bash): Introduction, shell responsibilities, pipes and input Redirection, output redirection, here documents, running a shell script, the shell as a programming language, shell meta characters, file name substitution, shell variables, command substitution, shell commands, the environment, quoting, test command, control structures, arithmetic in shell, shell script examples, interrupt processing, functions, debugging shell scripts. OBJECTIVES:

 To understand shell programming.

 Be able to work with shell.

Micro plan :

No. of Date S.No Topic lectures 1 Introduction, shell responsibilities 1 2 Pipes, Redirection 1 3 here documents, running a shell script 1 shell meta characters, file name substitution, shell 2 4 variables, command substitution shell commands, the environment, quoting, test 2 5 command control structures, arithmetic in shell, shell script 2 6 examples interrupt processing, functions, debugging shell 1 7 scripts Total 10

Assignments:

Q 1: Explain why we cannot use input redirection with the echo command.

Q 2: Identify at least 5 predefined variables and their use.

Q 3: Discuss shell Meta characters?

Q 4: Write a shell script to accept a string from the terminal and use `case' to echo a suitable message if the string does not have at least 10 characters using: i. case ii. expr Q5: Write a shell script to display the processes in the system five times every 30 Seconds using: i. while loop ii. for loop.

UNIT –III Syllabus: Files: File Concept, Files System Structure, Inodes, File Attributes, File Types, Library functions, the standard I/O and formatted I/O in C, stream errors, kernel support for files, System calls, file descriptors Low level file access: File structure related system calls (File APIs), file and record locking File and Directory Management: Directory file APIs, Symbolic links & hard links. Objectives:

 To understand File and Directory structure of Linux operating system.

 To know different file API’s. Micro Plan:

S.No Topic No. of lectures Date 1 File Concept, Files System Structure, Inodes 1 2 File Attributes, File Types, Library functions 1 3 the standard I/O and formatted I/O in C 2 4 stream errors, kernel support for files 1 5 System calls, file descriptors 2

6 File structure related system calls (File APIs), file 1 and record locking

7 Directory file APIs, Symbolic links & hard links 1

9 Total

Assignments: Q 1: Discuss about file and directory structure in LINUX?

Q 2: Explain about 1) files and devices 2) system calls 3) library functions?

Q 3: Explain with syntax and example open, create, read, write and lseek?

Q 4: Explain about all standard I/O functions with syntax?

Q 5: Explain about any 3 directory maintenance and handling commands with syntax?

UNIT-IV Syllabus: Process: Process concept, Kernel support for process, process attributes, process control-process creation, waiting for a process, process termination, zombie process, orphan process, Process APIs. Signals: Introduction to signals, Signal generation and handling, Kernel support for signals, Signal function, unreliable signals, reliable signals, kill, raise, alarm, pause, abort, sleep functions. Objectives:

 To understand processes and signals.

 Be able to know the kernel support for process & signals.

Micro Plan:

S.No Topic No. of lectures Date 1 Introduction, process structure& attributes, 1 2 waiting for a process, process creation & termination 1 3 Zombie process, Orphan process 1 4 Process identifiers 1 fork,vfork,exit,wait,exec 5 Signal functions, reliable and unreliable signals 1 6 Interuupted system calls 2 Kill,raise,alarm,pause,abort,system,sleep Total 7

Assignment: Q 1: What is process? Explain about process structure?

Q 2: Explain about zombie process and process control?

Q 3: Write the difference between fork and vfork, exit and wait?

Q 4: What are the signal functions? Explain about unreliable signals?

Q 5: Explain about interrupted system calls with syntax?

UNIT-V Syllabus: Inter-process Communications: Introduction to IPC, Pipes, FIFOs, Introduction to three types of IPC-message queues, semaphores and shared memory.

Message Queues: Kernel support for messages, Unix system V APIs for messages, client/server example.

Objectives:

 To understand IPC.

 To understand how kernel supports messages queues.

Micro Plan:

S.No Topic No. of lectures Date 1 Introduction to IPC 1 2 Pipes, FIFOs 1 3 Introduction to three types of IPC 1 4 Kernel support for messages 1 5 Unix system V APIs for messages 1 6 client/server example 2 Total 7

Assignments: Q 1: What is meant by IPC? Q 2: Explain about pipes and named pipes in IPC?

Q 3: Explain with example message queues?

Q 4: Explain with example semaphores?

Q 5: Explain the concept of shared memory with example? UNIT-VI Syllabus: Semaphores: Kernel support for semaphores, Unix system V APIs for semaphores.

Shared Memory: Kernel support for shared memory, Unix system V APIs for shared memory, semaphore and shared memory example.

Objectives:

 To understand kernel support semaphores and shared memory.

 To learn API’s for semaphores & shared memory.

Micro Plan:

S.No Topic No. of lectures Date 1 Kernel support for semaphores 1 2 Unix system V APIs for semaphores 2 3 Kernel support for shared memory 1 4 Unix system V APIs for shared memory 1 5 semaphore and shared memory example 2 Total 7

ASSIGNMENTS: Q 1: Explain about semaphores?

Q 2: Explain about shared memory?

Q 3: Explain with example semaphores?

Q 4: Explain with example shared memory?

Q 5: Explain the concept of shared memory with example? UNIT-VII Syllabus: Multithreaded Programming : Differences between threads and processes, Thread structure and uses, Threads and Lightweigth Processes, POSIX Thread APIs, Creating Threads, Thread Attributes, thread synchronization with semaphores and with Mutexes, Example program.

Objectives:

 To understand concept of multithreaded programming.

 To understand thread synchronization. Micro Plan:

S.No Topic No. of lectures Date 1 Differences between threads and processes 1 2 Thread structure and uses, Threads and 1 Lightweigth Processes 3 POSIX Thread APIs 1 4 Creating Threads, Thread Attributes 1 5 Thread synchronization with semaphores 1 6 Thread synchronization with Mutexes 1 7 Example program 1 Total 7

Assignment: Q 1: Explain differences between threads and processes?

Q 2: Explain about thread structure and its uses?

Q 3: How to create threads and explain thread attributes?

Q 4: Explain with example thread synchronization with semaphores?

Q 5: Explain with example thread synchronization with mutexes? UNIT –VIII Syllabus: Sockets: Introduction to sockets, Socket Addresses, Socket system calls for connection oriented protocol and connectionless protocol, example client/server programs.

Objectives:

 To understand the concepts of socket.

 Be familiar with socket programming.

Micro Plan:

S.No Topic No. of lectures Date 1 Introduction to sockets 1 2 Socket Addresses 1 3 Socket system calls for connection oriented 1 protocol 4 Socket system calls for connectionless protocol 1 5 example client/server programs 2 Total 6 Total no. of classes 64

Assignment: Q 1: Explain differences types of socket addresses?

Q 2: Explain about socket system calls for connection oriented protocol?

Q 3: Explain about socket system calls for connectionless protocol?

Recommended publications