Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Assignment No. 02 Semester: Fall 2014 CS604 –Operating System Total Marks: 15 Due Date: 10/12/2014

Uploading instructions:

 

  • Your assignment must be in .doc format. (Any other formats like scan images, PDF, Zip, rar, bmp,etc will not be accepted).
  • Save your assignment with your ID (e.g. bc020200786.doc).
  • No assignment will be accepted through email.

 

Rules for Marking:

 

It should be clear that your assignment will not get any credit if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file is corrupted.
  • Your assignment is copied from internet, handouts or from any other student

      (Strict disciplinary action will be taken in this case).

 

Assignment

 

Question 1:   (10 Marks)

 

Write a Unix/Linux base code for creating the pipe for showing the inter process communication,i.e. the child process send message “Hello world” to parent process, which reads it and displays it on the screen.

 

 

Question 2: (5 Marks)

 

Categorize the following examples into Interrupt, signal and traps:                         

 

  1. If you write the Code in c language, like a=b/0.
  2. Compile a C program and error occurs Invalid memory access or buffer overflow.
  3. While running a program, you press <Ctrl-C>.
  4. Fatima is doing chatting with her friend, by hitting keystrokes.
  5. Opening a folder by double clicking mouse.

 

 

NOTE:Do not put any query on MDB about this assignment, if you have any query then emailatcs604@vu.edu.pk.

 

Deadline: Your assignment must be uploaded/submitted on or before 10th Dec 2014.

Views: 6404

Attachments:

Replies to This Discussion

Got 5 marks bad marks indeed now want to improve so share your ideas about this assignment!

Interrupts: is a signal that is generated by hardware device (I/O device) to get CPU's attention

Traps: is a software-generated interrupt caused either by an error (division by zero or invalid memory access) or by a user request for an operating system services

Signal: a signal is a event generated to get attention of a process (like Ctrl-C)

  1. If you write the Code in c language, like a=b/0.                                                                                  traps
  2. Compile a C program and error occurs Invalid memory access or buffer overflow.                      traps
  3. While running a program, you press <Ctrl-C>.                                                                                   signal
  4. Fatima is doing chatting with her friend, by hitting keystrokes.                                                      interrupts
  5. Opening a folder by double clicking mouse.                                                                                       Interrupt 

An interrupt is a signal from a device attached to a computer or from a program within the computer that causes the main program that operates the computer (the operating system) to stop and figure out what to do next. Almost all personal (or larger) computers today areinterrupt-driven - that is, they start down the list of computer instruction s in one program (perhaps an application such as a word processor) and keep running the instructions until either (A) they can't go any further or (B) an interrupt signal is sensed. After the interrupt signal is sensed, the computer either resumes running the program it was running or begins running another program.

signal
A signal is a software interrupt delivered to a process. The operating system uses signals to report exceptional situations to an executing program. Some signals report errors such as references to invalid memory addresses; others report asynchronous events, such as disconnection of a phone line.

Interrupt and Trap
There are two hinderances to a process. Interrupt and trap.
Interrupt is when the process needs some I/O services whereas trap occurs due to some fault or exception in the code.

trap
A trap is an exception in a user process. It's caused by division by zero or invalid memory access. It's also the usual way to invoke a kernel routine (a system call) because those run with a higher priority than user code.

Question NO 2
 1. Trap
2. Trap
3. Signal
4. Interrupt
5. Interrupt

Question 2: (5 Marks)

Categorize the following examples into Interrupt, signal and traps:

1. If you write the Code in c language, like a=b/0.
2. Compile a C program and error occurs Invalid memory access or buffer overflow.
3. While running a program, you press .
4. Fatima is doing chatting with her friend, by hitting keystrokes.
5. Opening a folder by double clicking mouse.

1. Trap
2. Trap
3. Signal
4. Interrupt
5. Interrupt

plZZ discuss question#1 also

Let's solve it now.

 so, easy!

Q1:

==============================

Ans:

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
main()
{
int pipefd[2], pid, n, rc, nr, status;
char *testString = "Hello, world!\n“, buf[1024];
rc = pipe (pipefd);
if (rc < 0) {
perror("pipe");
exit(1);
}
pid = fork ();
if (pid < 0) {
perror("fork");
exit(1);
}
if (pid == 0) { 
close(pipefd[0]);
write(pipefd[1], testString, strlen(testString));
close(pipefd[1]);
exit(0);
}

close(pipefd[1]);
n = strlen(testString);
nr = read(pipefd[0], buf, nA);
rc = write(1, buf, nr);
wait(&status);
printf("Good work child!\n");
return(0);
}

Line 3  sys/wait.h: No such file or directory.

Code shows this error

where u tried it?

RSS

Looking For Something? Search Below

© 2022   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service