Matoshri College of Engineering & R. C. Nashik Department of Computer Engineering. Subject :- ADVANCE UNIX PROGRAMMING. M.E. Computer Engineering Semester:- 3 Subject I/c :- Mr. Ranjit Gawande. MODEL ANSWER – FOR May June 14

Model Ans. Paper for Advance Unix Programming 2013 Pat. Q1.A What are different types of Shell? Explain shell responsibilities in brief.[4] Ans.

[6]

Some operating systems include the command interpreter in the kernel. Others,such as Windows XP and UNIX, treat the command interpreter as a special program that is running when a job is initiated or when a user first logs on (on interactive systems). On systems with multiple command interpreters to choose from, the interpreters are known as shells. For example, on UNIX and Linux systems, a user may choose among several different shells, including the Bourne shell, C shell, Bourne-Again shell, Korn shell, and others. Third-party shells and free user written shells are also available. Most shells provide similar functionality, and a user's choice of which shell to use is generally based on personal preference.

The main function & shell responsibilities of the command interpreter is to get and execute the next user-specified command. Many of the commands given at this level manipulate files: create, delete, list, print, copy, execute, and so on. The MS-DOS and UNIX shells operate in this way. These commands can be implemented in two general ways. In one approach, the command interpreter itself contains the code to execute the command. For example, a command to delete a file may cause the command interpreter to jump to a section of its code that sets up the parameters and makes the appropriate system call. In this case, the number of commands that can be given determines the size of the command interpreter, since each command requires its own implementing code. An alternative approach -used by UNIX, among other operating systems implements most commands through system programs. Q1.B Explain the various features of IA-64 architectures in brief. Ans.

IA-64 features

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 1

[4]

• EPIC (Explicitly Parallel Instruction Computing) • Data types, memory and registers • Register stack • Predication and parallel compares • Software pipelining and register rotation • Control & data speculation • Branch architecture • Integer architecture • Floating point architecture 1) New EPIC Technology :- IA-64 Architecture uses EPIC 64 Architecture, uses EPIC Itanium processor is the first implementation of IA-64, Which achieve following features Parallelism Branches Procedure Calls Memory Latency

EPIC Design Philosophy EPIC Design Philosophy:a) Maximize performance via hardware & software synergy b) Advanced features enhance instruction level parallelism using Predication, Speculation c) Massive hardware resources for parallel execution

Q1C

Explain input and output redirection with a suitable example.

Ans.

The standard C library provides standard input and output streams ( stdin and stdout , respectively).These are used by scanf , printf , and other library functions. In the UNIX tradition, use of standard input and output is customary for GNU/Linux programs. This allows the chaining of multiple programs using shell pipes and input and output redirection. The C library also provides stderr , the standard error stream. Programs should print warning and error messages to standard error instead of standard output. This allows users to separate normal output and error messages, for instance, by redirecting standard output to a file while allowing standard error to print on the console. The fprintf function can be used to print to stderr , for example: fprintf (stderr, (“Error: ...”)); These three streams are also accessible with the underlying UNIX I/O commands ( read , write , and so on) via file descriptors. These are file descriptors 0 for stdin , 1 for stdout , and 2 for stderr .

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 2

When invoking a program, it is sometimes useful to redirect both standard output and standard error to a file or pipe.The syntax for doing this varies among shells; for Bournestyle shells (including bash , the default shell on most GNU/Linux distributions), the syntax is this: % program > output_file.txt 2>&1 % program 2>&1 | filter The 2>&1 syntax indicates that file descriptor 2 ( stderr ) should be merged into file descriptor 1 ( stdout ). Note that 2>&1 must follow a file redirection but must precede a pipe redirection. OR Q2A

Explain Signal Set data type with five functions used to manipulate signals. [5]

Ans.

POSIX defines a data structure which holds one bit for each possible signal. This data structure is named signal set. It is an integer like data type. An integer is at least 32 bit value in 32 bit architectures. So we can hold status information for 32 different signals. We can define signal mask as a signal set. We can manage them by using some custom functions. POSIX defines some functions to modify any given signal set. Signal sets are being used to represent multiple signals in a data structure. sigset_t *set It is not a feasible solution to allocate an integer for each signal. In some architectures, number of signals can exceed the number of bits in an integer. Signal sets solve this portability problem. POSIX has these functions to manipulate signal sets: NAME sigemptyset, sigfillset, sigaddset, sigdelset, sigismember -manipulate signal sets LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include For Manipulation sigprocmask() NAME sigprocmask -- manipulate current signal mask SYNOPSIS #include

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 3

[6]

int sigprocmask(int how, const sigset_t *set, sigset_t *oset); This function manipulates current signal mask which shows currently blocked signals. If the set is specified, the function installs new signal set instead of the current one. 'how' indicates how the current mask is modified. It can be SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK. If SIG_BLOCK is selected, the new mask is the union of the current mask and the specified set. If SIG_UNBLOCK is selected, the new mask is the intersection of the current mask and the complement of the specified set. If how is SIG_SETMASK, the current mask is replaced by the specified set. If set is NULL, how won't be affected and the process signal mask will not be changed.  If oset is not NULL, it preserves the previous value of the signal mask. 

Notice that, SIGKILL and SIGSTOP cannot be blocked. Following are remaining 2 manipulate function used in signal set. Sigpending() :- It returns pending signals as a signal set. Remember: if a signal is between generation and delivery, signal is called pending. 'set' parameter will include returned set. Sigaction() :- A process may specify a handler for a particular signal by using sigaction. It is similar to the signal() call as in unreliable signals.

Q2B

How does wait ( ) and waitpid ( ) work? [2]

Ans.

The wait System Calls The function wait . It blocks the calling process until one of its child processes exits (or an error occurs). It returns a status code via an integer pointer argument, from which you can extract information about how the child process exited. For instance, the WEXIT STATUS macro extracts the child process’s exit code. waitpid ( ) Several similar system calls are available in Linux, which are more flexible or provide more information about the exiting child process. The waitpid function can be used to wait for a specific child process to exit instead of any child process. The wait3 function returns CPU usage statistics about the exiting child process, and the wait4 function allows you to specify additional options about which processes to wait for.

Q2.c

Write a note on Memory Mapped I/O. [5]

Ans.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 4

[4]

Memory Mapped I/O with the VAX DZ1 1 Controller The precise method in which a driver communicates with a device depends on the hardware. Some machines provide memory mapped I/0, meaning that certain addresses in the kernel address space are not locations in physical memory but are special registers that control particular devices. By writing control parameters to specified registers according to hardware specifications, the driver controls the device. For example, 110 controllers for the VAX- 1 1 computer contain special registers for recording device status (control and status registers) and for data transmission (data buffer registers) , which are configured at specific addresses in physical memory. In particular, the VAX DZ l l terminal controller controls 8 asynchronous lines for terminal communication . Assume that the control and status register of a particular D Z 1 1 is at address 160120, the transmit data buffer register is at address 160126, and the receive data buffer register is at address 60122 (Figure above) . To write a character to terminal "/dev/tty09", the terminal driver writes the number 1 ( 1 modulo 8) to a specified · bit position in the control and status register and then writes the character to the transmit data buffer register . The operation of writing the transmit data buffer register transmits the data. The D Z 1 1 controller sets a done bit in the control and status register when it is ready to accept more data. The driver can optionally set a transmit interrupt enable bit in the control and status register , which causes the DZ 1 1 controller to interrupt the system when it is ready to accept more data. Reading data from the D Z 1 1 is similar.

Q3.A What is the basic difference between select ( ) & pselect ( ) functions used in I/O multiplexing? [5] Ans.  select() and pselect() allow a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" for some class of I/O operation (e.g., input possible). A file descriptor is considered ready if it is possible to perform the corresponding I/O operation (e.g., read(2)) without blocking. We want to be notified if one or more I/O conditions are ready (i.e., input is ready to be read, or the descriptor is capable of taking more output). This capability is called I/O multiplexing and is provided by the select and poll functions, as well as a newer POSIX variation of the former, called pselect.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 5

[6]

Sr. No.

select()

pselect()

1

select() uses a timeout that is a struct timeval (with seconds and microseconds)

pselect() uses a struct timespec (with seconds and nanoseconds).

2

select() may update the timeout pselect() does not change this argument. argument to indicate how much time was left.

3

select() has no sigmask argument, and behaves as

pselect() called with NULL sigmask.

Three independent sets of file descriptors are watched. Listed in readfds will be watched to see if characters become available for reading (more precisely, to see if a read will not block; in particular, a file descriptor is also ready on end-of-file),those in writefds will be watched to see if a write will not block, and those in exceptfds will be watched for exceptions. On exit, the sets are modified in place to indicate which file descriptors actually changed status. Each of the three file descriptor sets may be specified as NULL if no file descriptors are to be watched for the corresponding class of events. Four macros are provided to manipulate the sets. • FD_ZERO() clears a set. •

FD_SET() and



FD_CLR() respectively add and remove a given file descriptor from a set.



FD_ISSET() tests to see if a file descriptor is part of the set;

this is useful after select() returns. nfds is the highest-numbered file descriptor in any of the three sets, plus 1. timeout is an upper bound on the amount of time elapsed before select() returns. It may be zero, causing select() to return immediately. (This is useful for polling.) If timeout is NULL (no timeout), select() can block indefinitely. sigmask is a pointer to a signal mask (see sigprocmask(2)); if it is not NULL, then pselect() first replaces the current signal mask by the one pointed to by sigmask, then does the ‘select’ function, and then restores the original signal mask.

Q3.B Explain the rules that govern the inheritance and release of locks in record locking.[4] Ans.  There are 3 important rules regarding automatic inheritance and release of record locks: 1. Locks are associated with a process and a file. When a process terminates, all its locks are released. Whenever a descriptor is closed, any locks on the file referenced by that descriptor for that process are released. 2. Locks are never inherited by the child across a fork (otherwise we could end up with two processes sharing a write lock) 3. Locks may be inherited by a new program across an exec. This is not required by POSIX.1 and therefore machine dependent

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 6

[4]

Record locking is the term normally used to describe the ability of a process to prevent other processes from modifying a region of a file while the first process is reading or modifying that portion of the file. Under the UNIX System, "record" is a misnomer; the UNIX kernel does not have a notion of records in a file. A better term is byte-range locking, given that it is a range of a file (possibly the entire file) that is locked. Record locking was added to System V Release 3 through the fcntl function. The lockf function was built on top of this, providing a simplified interface. These functions allowed callers to lock arbitrary byte ranges in a file, ranging from the entire file down to a single byte within the file. OR Q4.A Write a note on Record Locking. [4] Ans. 

Record locking is the term normally used to describe the ability of a process to prevent other processes from modifying a region of a file while the first process is reading or modifying that portion of the file. Under the UNIX System, "record" is a misnomer; the UNIX kernel does not have a notion of records in a file. A better term is byte-range locking, given that it is a range of a file (possibly the entire file) that is locked. Record locking was added to System V Release 3 through the fcntl function. The lockf function was built on top of this, providing a simplified interface. These functions allowed callers to lock arbitrary byte ranges in a file, ranging from the entire file down to a single byte within the file. A record is any contiguous sequence of bytes in a file. The UNIX operating system does not impose any record structure on files. The boundaries of records are defined by the programs that use the files. Within a single file, a record as defined by one process can overlap partially or completely on a record as defined by some other process. Read (Shared) Lock A read lock keeps a record from changing while one or more processes read the data. If a process holds a read lock, it may assume that no other process can alter that record at the same time. A read lock is also a shared lock because more than one process can place a read lock on the same record or on a record that overlaps a read-locked record. No process, however, can have a write lock that overlaps a read lock. Write (Exclusive) Lock A write lock is used to gain complete control over a record. A write lock is an exclusive lock because, when a write lock is in place on a record, no other process may read- or write-lock that record or any data that overlaps it. If a process holds a write lock it can assume that no other process will read or write that record at the same time.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 7

[4]

Advisory Locking An advisory lock is visible only when a program explicitly tries to place a conflicting lock. An advisory lock is not visible to the file I/O system functions such asread()andwrite(). A process that does not test for an advisory lock can violate the terms of the lock, for example, by writing into a locked record. Advisory locks are useful when all processes make an appropriate record lock request before performing any I/O operation. When all processes use advisory locking, access to the locked data is controlled by the advisory lock requests. The success of advisory locking depends on the cooperation of all processes in enforcing the locking protocol; it is not enforced by the file I/O subsystem. Mandatory Locking Mandatory record locking is enforced by the file I/O system functions, and so is effective on unrelated processes that are not part of a cooperating group. Respect for locked records is enforced by thecreat(),open(),read(), andwrite()system calls. When a record is locked, access to that record by any other process is restricted according to the type of lock on the record. Cooperating processes should still request an appropriate record lock before an I/O operation, but an additional check is made by IRIX before each I/O operation to ensure the record locking protocol is being honored. Mandatory locking offers security against unplanned file use by unrelated programs, but it imposes additional system overhead on access to the controlled files.

Q4.B How does pipe and FIFO IPC mechanism differ? [2] Ans.  FIFOs are sometimes called named pipes. Unnamed pipes can be used only between related processes when a common ancestor has created the pipe. With FIFOs, however, unrelated processes can exchange data. FIFO is a type of file. One of the encodings of the st_mode member of the stat structure indicates that a file is a FIFO. We can test for this with the S_ISFIFO macro. Creating a FIFO is similar to creating a file. Indeed, the pathname for a FIFO exists in the file system. Pipes are the oldest form of UNIX System IPC and are provided by all UNIX systems. Pipes have two limitations. 1) they have been half duplex (i.e., data flows in only one direction). 2) Pipes can be used only between processes that have a common ancestor. This 2nd limitation can be overcome with the help of FIFO. There are two uses for FIFOs. 1) FIFOs are used by shell commands to pass data from one shell pipeline to another without creating intermediate temporary files. 2) FIFOs are used as rendezvous points in client–server applications to pass data between the clients and the servers. FIFOs, message queues, semaphores, and shared memory are the classical methods of IPC provided by various UNIX systems. These mechanisms allow processes running on the same computer to communicate with one another.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 8

[6]

Q5.A Explain the client-server communication using FIFO in Unix with a suitable diagram. [6]

[8]

Ans. 

For each client to send its process ID with the request. The server then creates a unique FIFO for each client, using a pathname based on the client’s process ID. For example, the server can create a FIFO with the name /tmp/serv1.XXXXX, where XXXXX is replaced with the client’s process ID. This arrangement is shown in above figure. This arrangement overcome the drawback that for the server to tell whether a client crashes. A client crash leaves the client-specific FIFO in the file system. The server also must catch SIGPIPE, since it’s possible for a client to send a request and terminate before reading the response, leaving the client-specific FIFO with one writer (the server) and no reader. With the arrangement shown in above figure , if the server opens its well-known FIFO read-only (since it only reads from it) each time the number of clients goes from 1 to 0, the server will read an end of file on the FIFO. To prevent the server from having to handle this case, a common trick is just to have the server open its well-known FIFO for read–write. Q5.B Write a short note on IPC using Message queue. [4] Ans.  The three types of IPC that usually call XSI IPC—message queues, semaphores, and shared memory, these have many similarities. Message Queues A message queue is a linked list of messages stored within the kernel and identified by a message queue identifier. We’ll call the message queue just a queue and its identifier a queue ID. A new queue is created or an existing queue opened by msgget. New messages are added to the end of a queue by msgsnd. Every message has a positive long integer type field, a non-negative length, and the actual data bytes (corresponding to the length), all of which are specified to msgsnd when the message is added to a queue. Messages are fetched from a queue by msgrcv. We don’t have to fetch the messages in a first-in, first-out order. Instead, we can fetch messages based on their type field. Each queue has the following msqid_ds structure associated with it: struct msqid_ds { struct ipc_perm          msg_perm; msgqnum_t                msg_qnum; ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 9

[8]

msglen_t                    msg_qbytes; pid_t                          msg_lspid; pid_t                          msg_lrpid; time_t                           msg_stime; time_t                           msg_ctime;        ...    }; This structure defines the current status of the queue. The members shown are the ones defined by the Single UNIX Specification.

Q6.A Explain the importance of unlink ( ) in case of FIFO. [3]

[8]

Ans.  Once we have used mkfifo or mkfifoat to create a FIFO, we open it using open. Indeed, the normal file I/O functions (e.g., close, read, write, unlink) all work with FIFOs. When we are done with the semaphore, we can call the sem_close function to release any resources associated with the semaphore.

#include int sem_close(sem_t *sem); Returns: 0 if OK, 1 on error If our process exits without having first called sem_close, the kernel will close any open semaphores automatically. Note that this doesn’t affect the state of the semaphore value if we have incremented its value, this doesn’t change just because we exit. Similarly, if we call sem_close, the semaphore value is unaffected. There is no mechanism equivalent to the SEM_UNDO flag found with XSI semaphores. To destroy a named semaphore, we can use the sem_unlink function. #include int sem_unlink(const char *name); Returns: 0 if OK, 1 on error The sem_unlink function removes the name of the semaphore. If there are no open references to the semaphore, then it is destroyed. Otherwise, destruction is deferred until the last open reference is closed. Note that we unlink the semaphore after opening it. This destroys the name so that no other process can access it and simplifies cleanup when the process ends. Q6.B Explain in detail SHM _LOCK and SHM _UNLOCK commands. [3] Ans. 

Two additional commands are provided by Linux and Solaris, but are not part of the Single UNIX Specification. SHM_LOCK :- Lock the shared memory segment in memory. This command can be ….......................executed only by the superuser. SHM_UNLOCK :- Unlock the shared memory segment. This command can be executed …...........................only by the superuser.

The cmd argument specifies one of the above commands to be performed, on the segment specified by shmid.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 10

[8]

Q7.A What is a socket? Explain different types of socket? [4]

[8]

Ans.  The mechanisms that allow processes running on different computers (connected to a common network) to communicate with one another network IPC. Socket network IPC interface, which can be used by processes to communicate with other processes, regardless of where they are running on the same machine or on different machines. Indeed, this was one of the design goals of the socket interface. The same interfaces can be used for both inter-machine communication and intra-machine communication. Although the socket interface can be used to communicate using many different network protocols. The socket API as specified by POSIX.1 is based on the 4.4BSD socket interface. Socket Descriptors A socket is an abstraction of a communication endpoint. Just as they would use file descriptors to access files, applications use socket descriptors to access sockets. Socket descriptors are implemented as file descriptors in the UNIX System. Indeed, many of the functions that deal with file descriptors, such as read and write, will work with a socket descriptor. To create a socket, we call the socket function. #include int socket(int domain, int type, int protocol); Returns: file (socket) descriptor if OK, 1 on error The domain argument determines the nature of the communication, including the address format (domains specified by POSIX.1) There are four types of sockets available to the users. The first two are most commonly used and the last two are rarely used. Processes are presumed to communicate only between sockets of the same type but there is no restriction that prevents communication between sockets of different types. Stream Sockets − Delivery in a networked environment is guaranteed. If you send through the stream socket three items "A, B, C", they will arrive in the same order − "A, B, C". These sockets use TCP (Transmission Control Protocol) for data transmission. If delivery is impossible, the sender receives an error indicator. Data records do not have any boundaries. Datagram Sockets − Delivery in a networked environment is not guaranteed. They're connectionless because you don't need to have an open connection as in Stream Sockets − you build a packet with the destination information and send it out. They use UDP (User Datagram Protocol). Raw Sockets − These provide users access to the underlying communication protocols, which support socket abstractions. These sockets are normally datagram oriented, though their exact characteristics are dependent on the interface provided by the protocol. Raw sockets are not intended for the general user; they have been provided mainly for those interested in developing new communication protocols, or for gaining access to some of the more cryptic facilities of an existing protocol. Sequenced Packet Sockets − They are similar to a stream socket, with the exception that record boundaries are preserved. This interface is provided only as a part of the Network Systems (NS) socket abstraction, and is very important in most serious NS applications. Sequenced-packet sockets allow the user to manipulate the Sequence Packet Protocol (SPP) or Internet Datagram Protocol (IDP) headers on a packet or a group of packets, either by writing a prototype header along with whatever data is to be sent, or by specifying a default header to be used with all outgoing data, and allows the user to receive the headers on incoming packets. Q7.B Write a note on RPC. [3] ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 11

[8]

Ans.  The rpcbind daemon provides the service of mapping RPC (Remote Procedure Call) program numbers to network port numbers. The rsyslogd daemon is available to any program to log system messages for an administrator. The messages may be printed on a console device and also written to a file. The inetd daemon listens on the system’s network interfaces for incoming requests for various network servers. The nfsd, nfsiod, lockd, rpciod, rpc.idmapd, rpc.statd, and rpc. mountd daemons provide support for the Network File System (NFS). Note that the first four are kernel daemons, while the last three are user-level daemons RPC is a powerful technique for constructing distributed, client-server based applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not exist in the same address space as the calling procedure. The two processes may be on the same system, or they may be on different systems with a network connecting them. By using RPC, programmers of distributed applications avoid the details of the interface with the network. The transport independence of RPC isolates the application from the physical and logical elements of the data communications mechanism and allows the application to use a variety of transports. RPC makes the client/server model of computing more powerful and easier to program. When combined with the ONC RPCGEN protocol compiler clients transparently make remote calls through a local procedure interface.

Q8.A What files are generated by rpcgen? List the server specific files. [3] Ans.  The rpcgen tool generates remote program interface modules. It compiles source code written in the RPC Language. RPC Language is similar in syntax and structure to C. rpcgen produces one or more C language source modules, which are then compiled by a C compiler. The default output of rpcgen is: A header file of definitions common to the server and the client A set of XDR routines that translate each data type defined in the header file A stub program for the server A stub program for the client The rpcgen provides programmers a simple and direct way to write distributed applications. Server procedures may be written in any language that observes procedure-calling conventions. They are linked with the server stub produced by rpcgen to form an executable server program. Client procedures are written and linked in the same way. To compile the remote rprintmsg example: • compile the protocol defined in msg.x: rpcgen msg.x. This generates the header files (msg.h), client stub (msg_clnt.c), and server stub (msg_svc.c). • compile the client executable: cc rprintmsg.c msg_clnt.c -o rprintmsg -lnsl • compile the server executable: cc msg_proc.c msg_svc.c -o msg_server -lnsl Once created, the server program is installed on a remote machine and run. (If the ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 12

[8]

machines are homogeneous, the server binary can just be copied. If they are not, the server source files must be copied to and compiled on the remote machine.) Q8.B What are different models of concurrent server design? Explain any one model in detail. [4] Ans.  Different models of concurrent server design 1. One child process per client 2. Spawn one thread per client 3. Preforking multiple processes 4. Prethreaded Server

There are two main classes of servers, iterative and concurrent. An iterative server iterates through each client, handling it one at a time. A concurrent server handles multiple clients at the same time. The simplest technique for a concurrent server is to call the fork function, creating one child process for each client. An alternative technique is to use threads instead (i.e., light-weight processes). The fork() function The fork() function is the only way in Unix to create a new process. It is defined as follows: #include

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 13

[8]

pid_t fork(void); The function returns 0 if in child and the process ID of the child in parent; otherwise, -1 on error. In fact, the function fork() is called once but returns twice. It returns once in the calling process (called the parent) with the process ID of the newly created process (its child). It also returns in the child, with a return value of 0. The return value tells whether the current process is the parent or the child. When a connection is established, accept returns, the server calls fork, and the child process services the client (on the connected socket connfd). The parent process waits for another connection (on the listening socket listenfd. The parent closes the connected socket since the child handles the new client. The interactions among client and server are presented in above figure.

Q9.A Write short notes on the following. 1) Socket descriptor. 2) Socket address structure for IP4.

[6]

Ans.  Q9.B What type of operations are supported on routing sockets?

[6]

Ans.  Note:- This literature is only for private circulation.

Matoshri College of Engineering & R. C. Nashik Department of Computer Engineering. Subject :- ADVANCE UNIX PROGRAMMING. M.E. Computer Engineering Semester:- 3 Subject I/c :- Mr. Ranjit Gawande. MODEL ANSWER – FOR  May June 16

Model Ans. Paper for Advance Unix Programming 2013 Pat. Q1.A What is the purpose of grep command? Explain the various options available with the grep command with an example. [4]

[6]

Ans. Q1.B Define file. Explain in detail about the various files. [4]

[4]

Ans.

Q2A

Explain the concept of journaling in ext4 file system? [2]

Ans. ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 14

[5]

Q2B

Explain the various features of IA-64 architectures in brief. [5]

[5]

Ans. Q3.A What are the phases in signaling process? Explain what is meant by the lifetime of a signal. [5]

[4]

Ans.  Q3.B What is meant by process termination? Explain the various types of process terminations [6] with a suitable example. [5] Ans. 

Q4.A Explain Record locking in Unix using fcntl( ). [3]

[4]

Ans.  Q4.B Explain the working of kill and raise functions. [2]

[6]

Ans.  Q5.A Write a note on file locking versus Record Locking. [4]

[8]

Ans.  Q5.B What do you mean by slow system call? What action is expected to overcome the effect of system call? [4]

[8]

Ans. 

Q6.A Explain Copy On Write(COW) concept in UNIX. [2]

[8]

Ans.  Q6.B Explain the client-server communication using FIFO in Unix with a suitable diagram. [6]

[8]

Ans. 

Q7.A With an example, explain in detail about the process of reading and writing a message from the message queue. [4] ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 15

[8]

Ans.  Q7.B What is a semaphore? Explain how to synchronize processes using semaphores. [4]

[8]

Ans. 

Q8.A Explain in detail SHM_LOCK and SHM_UNLOCK in Shared memory IPC. [4]

[8]

Ans.  Q8.B Explain the importance of unlink ( ) in case of FIFO. [2]

[8]

Ans.  Q9.A Compare the different designs of concurrent servers. [6]

[12]

Ans.  Q9.B How does synchronization take place in multithreading? [4]

[6]

Ans. 

Q10.A Explain in detail IPv4 socket structure with a suitable diagram. [4]

[12]

Ans.  Q10.B Explain the role of various socket functions in client server communication. [4] Ans.  Q10.C Write a short note on daytime server. Note:- This literature is only for private circulation.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 16

[6]

Matoshri College of Engineering & R. C. Nashik Department of Computer Engineering. Subject :- ADVANCE UNIX PROGRAMMING. M.E. Computer Engineering Semester:- 3 Subject I/c :- Mr. Ranjit Gawande. MODEL ANSWER – FOR  NOV DEC 14

Model Ans. Paper for Advance Unix Programming 2013 Pat. Q1.A Explain the concept of journaling in ext 4 file system? Describe three types of journaling [4] available in ext4 file system. [4] Ans. Q1.B Explain IA-64 architecture with a suitable diagram. [5]

[6]

Ans.

Q2A

What is a shell? Explain various shell responsibilities in brief. [4]

[8]

Ans. Q2B

What happens on fork () system call execution? Which properties are inherited by the child from the parent? [5]

Ans.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 17

[2]

Q3.A How is Non-Local Goto handled by using setjmp ( ) and longjmp ( ). Explain with an example.[5]

[6]

Ans.  Q3.B Explain the working of unreliable and reliable signals in Unix. [3]

[4]

Ans. 

Q4.A Explain in detail Virtual Memory Management in Unix. [4]

[4]

Ans.  Q4.B Define process and explain process management in Unix. [4]

[6]

Ans.  Q5.A What is the basic difference between select () & pselect () functions used in I/O multiplexing? [4]

[8]

Ans.  Q5.B Write a note on Record Locking. [4]

[8]

Ans. 

Q6.A Which are the characteristics of buffering? Also describe the types of buffering. [6]

[8]

Ans.  Q6.B Compare Advisory locking with Mandatory locking. [2]

[8]

Ans. 

Q7.A Compare and contrast the various IPC mechanisms: Pipe, FIFO, Message Queue and semaphores. [8]

[8]

Ans.  Q7.B Explain the process of writing and reading data from PIPES. [4] Ans.  ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 18

[8]

Q8.A Explain Shared Memory structure maintained by Kernel in detail. [4]

[8]

Ans.  Q8.B How does synchronization take place in multithreading? [4]

[8]

Ans.  Q9.A What is Multiprocessor interface? Explain in detail. [4]

[6]

Ans.  Q9.B Discuss the significance of stub in RPC. [3]

[6]

Ans.  Q9.C Write a code to explain Prethreading creation and termination. [5]

[6]

Ans. 

Q10.A Write a program to design simple client and server communication using sockets. [5]

[6]

Ans.  Q10.B What is socket? Compare and contrast UNIX Domain sockets with Raw sockets. [4]

[6]

Ans.  Q10.C Explain in detail IPv4 socket structure with a suitable diagram. [4] Ans.  Q11A. What is a socket? Explain the different types of sockets? [5] Ans.  Note:- This literature is only for private circulation.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 19

[6]

Matoshri College of Engineering & R. C. Nashik Department of Computer Engineering. Subject :- ADVANCE UNIX PROGRAMMING. M.E. Computer Engineering Semester:- 3 Subject I/c :- Mr. Ranjit Gawande. MODEL ANSWER – FOR  NOV DEC 15

Model Ans. Paper for Advance Unix Programming 2013 Pat. Q1.A What is the purpose of grep command? Explain the various options available with the grep command with an example. [4]

[4]

Ans. Q1.B Write short notes on the following: I) Process utilities. ii) Disk utilities. [4]

[6]

Ans.

Q2A

Explain the two methods of altering file access permissions of a file.[2]

[8]

Ans. Q2B

Explain the various features of IA-64 architectures in brief. [5]

Ans.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 20

[2]

Q3.A Explain the following system calls with syntax : [3] I) Setjmp ( ). ii) Longjmp ( ). iii) Exit ( ).

[6]

Ans.  Q3.B Write a note on Reliable signal Handling [2]

[4]

Ans. 

Q4.A Explain about the various possible signal default actions. [3]

[4]

Ans.  Q4.B Write a note on Memory Mapped I/ O. [5]

[6]

Ans.  Q5.A Explain the differences between exit () & atexit () system calls? [2]

[8]

Ans.  Q5.B

What do you mean by slow system call ? What action is expected to overcome the effect of system call? [4]

[8]

Ans. 

Q6.A What is record lock? What are the rules about the specification of the region to be locked [8] or unlocked? [4] Ans.  Q6.B Explain Copy on Write ( COW) concept in UNIX. [2]

[8]

Ans. 

Q7.A What are the named pipes? Explain in detail. [4]

[8]

Ans.  Q7.B Explain in detail SHM LOCK and SHM IPC. UNLOCK in Shared memory [4] Ans.  ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 21

[8]

Q8.A Explain the importance of unlink ( ) in case of FIFO. [2]

[8]

Ans.  Q8.B Compare and contrast the various IPC mechanisms: FIFO, Message Queue and semaphores. [6]

[8]

Ans.  Q9.A What is the role of shared memory in group communication? Explain with a suitable example. [4]

[6]

Ans.  Q9.B What are different models of concurrent server design? Explain any one model in detail. [6]

[6]

Ans.  Q9.C Write a note on RPC. [4]

[6]

Ans. 

Q10.A Write short notes on the following. I) Socket address structure for IPv4. ii) Socket descriptor.

[6]

Ans.  Q10.B Explain in detail TCP and UDP sockets. Ans.  Note:- This literature is only for private circulation.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Department of Computer Engineering M.C.E.R.C. Nashik. M. E. Computer Engineering Sem – 3 Subject:- AUP Page no 22

[6]

AUP_edited_model ans paper.pdf

Procedure Calls. Memory Latency. EPIC Design Philosophy EPIC Design Philosophy:- a) Maximize performance via hardware & software synergy. b) Advanced ...

530KB Sizes 3 Downloads 236 Views

Recommend Documents

Ans-b Ans-a Ans-c -
10. How to capture on tab out event in js? a. On Tabout b. On Blur c. OffClick d. .... Array of 10 empty strings d. string ",,,,,,,,,," .... Microsoft Internet Explorer 3.0 e.

oqlw ans key.pdf
Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. oqlw ans key.pdf. oqlw ans key.pdf. Open.

ans key eighth.pdf
Green carpet – the earth. 7.It unites with the breeze to announce the coming of light. 8.Metaphor. 9.A star fallen from the blue tent. 10.On the eve of Teacher's day.

sheniblog_modelexam2018_physics ans key.pdf
Try one of the apps below to open or edit this item. sheniblog_modelexam2018_physics ans key.pdf. sheniblog_modelexam2018_physics ans key.pdf. Open.

Orléans Mairie - Déploiement ACCEO Orléans 2311.pdf
deuxième écran, sur un poste informatique équipé d'une webcam et d'un casque avec micro. La liaison est alors. établie avec un interprète Langue des Signes ...

Werbewirkungsforschung-Neue-Ans-tze-Durch-Neuromarketing ...
Page 1 of 3. Download ]]]]]>>>>>PDF Download Werbewirkungsforschung: Neue Ansätze Durch Neuromarketing (German Edition).

LSS 2017 Ans Key.pdf
Page 1 of 6. Generated by CamScanner from intsig.com. Page 1 of 6. Page 2 of 6. Generated by CamScanner from intsig.com. Page 2 of 6. Page 3 of 6. Generated by CamScanner from intsig.com. Page 3 of 6. LSS 2017 Ans Key.pdf. LSS 2017 Ans Key.pdf. Open.

LSS 2017 Ans Key.pdf
Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. LSS 2017 Ans Key.pdf. LSS 201

computer exam questions & Ans -
9. Documents converted to….. can be published to the web. (a) A doc file (b) HTTP (c) machine language ...... (D) Notebook computer (E) None of these (Ans : D).

Test Review Ans key.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Test Review Ans key.pdf. Test Review Ans key.pdf. Open. Extract.

USS 2017 ANS KEY-1.pdf
Page 1 of 2. Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code Qn. No. Code. 1 C 1 C 1 B 1 D 16 ...

+1 Eco Ans Key Sep 16.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. +1 Eco Ans Key Sep 16.pdf. +1 Eco Ans Key Sep 16.pdf. Open.

Spandanam_Socialannual ans key SS 9 th Eng.Med.pdf ...
Spandanam_Socialannual ans key SS 9 th Eng.Med.pdf. Spandanam_Socialannual ans key SS 9 th Eng.Med.pdf. Open. Extract. Open with. Sign In. Main menu.

2a - Article 25 ans - AutoLoisirs - 032014 - FR.pdf
Page 1 of 3. REVISTA CIENTÍFICA ELETRÔNICA DE MEDICINA VETERINÁRIA - ISSN 1679-7353. PUBLICAÇÃO CI ENTÍFICA DA FACULDADE DE MEDICINA VETERINÁRIA E ZOOTECNIA DE GARÇA/FAMED. ANO IV, NÚMERO, 08, JANEIRO DE 2007. PERIODICIDADE: SEMESTRAL ...

2014 M1 Sec 1 Phy Test 2 (ANS)
Answer to Physics Module 1 Test 2. Section A. Q1 (D) Q2 (B) Q3 (C) Q4 (A) Q5 (D). Section B. Q1 (Tape Measure/Measuring Tape, Micrometer Screw Gauge, ...

138 - LA LOUVIERE - 21.06.2015 - 6 7 ans - FILLES.pdf
Jun 21, 2015 - 35 » RABIATOU DIALLO 2008 2045 05:37. 36 » GABRIELLE DUPONT 2008 2499 05:37. 37 » JUNO DONFUT 2008 2036 05:40. 38 » LALIE ...

2015 KSet III Paper With Ans-signed.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. 2015 KSet III ...

unit-3-qb-w-ans 4- BY Civildatas.blogspot.in.pdf
PART - A (2 marks). 1. Write about ... Define bond stress. The tangential or shear stress ... unit-3-qb-w-ans 4- BY Civildatas.blogspot.in.pdf. unit-3-qb-w-ans 4- BY ...

eeiinotes-2-marks-with-ans-question-papers 1- BY Civildatas ...
Page 1 of 97. TABLE OF CONTENT. S. NO. TITTLE PAGE NO. 1 Unit I planning For Sewerage System 1. 1.1 Introduction 1. 1.2 Importance Of Sewerage System 2. 1.3 Definitions Of Some Common Terms Used In The. Sanitary Engineering. 3. 1.4 Different Methods

IA 1 3.1-3.14 ans key.pdf
Page 1 of 5. Page 1 of 5. Page 2 of 5. Page 2 of 5. Page 3 of 5. Page 3 of 5. IA 1 3.1-3.14 ans key.pdf. IA 1 3.1-3.14 ans key.pdf. Open. Extract. Open with. Sign In.

doppler and decibel ans key .pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. doppler and decibel ans key .pdf. doppler and decibel ans key .pdf. Open. Extract. Open with. Sign In. Main

rahe-2m-with-ans-16m-q 3- BY Civildatas.blogspot.in.pdf
Page 1 of 15. CE 6604 RAILWAYS, AIRPORT AND. HARBOUR ENGINEERING. (REGULATION-2013). UNIT – I. RAILWAY PLANNING. 1. Define Permanent way? The combination of rails, fitted on sleepers and resting on ballast and sub grade is called the. Railway track

Spandanam_SS Ans-Key VIII MM_Biju&Colin.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Spandanam_SS ...