Welcome to Premium Paper Help

#include “types.h” #include “user.h” #include “param.h” #define assert(x) if (x) { /* pass */ } else { \ printf(1, “assert failed %s %s %d\n”,

#include “types.h”
#include “user.h”
#include “param.h”

#define assert(x) if (x) { /* pass */ } else { \
printf(1, “assert failed %s %s %d\n”, #x , __FILE__, __LINE__); \
exit(); \
}

void readfile(char *file, int howmany) {
int i;
// assumes file opens successfully…
int fd = open(file, 0);
char buf;
// assumes file is big enough…
for (i = 0; i < howmany; i++)
(void) read(fd, &buf, 1);
close(fd);
}

int
main(int argc, char *argv[])
{
int rc1 = getreadcount();
printf(1, “Read count %d\n”, rc1);
int rc = fork();
if (rc < 0) {
printf(1, “Fork failed!\n”);
exit();
}
readfile(“README”, 5);
if (rc > 0) {
wait();
int rc2 = getreadcount();
printf(1, “Read count %d\n”, rc2);
assert((rc2 – rc1) == 10);
printf(1, “TEST PASSED\n”);
int fd1 = open(“ls”, 0);
int fd2 = open(“syscallTest”, 0);
int fd3 = open(“cat”, 0);
if(fd1 * fd2 * fd3 < 0){
printf(1, “Open failed!\n”);
exit();
}
close(fd1);
int of = getopenfilecount();
printf(1, “Number of opened files %d\n”, of – 3);
assert(of == 5);
printf(1, “TEST PASSED\n”);
close(fd2);
close(fd3);
}
exit();
}

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

CASE STUDY: FEDERAL/STATE/LOCAL COLLABORATION NETWORKS IN DISASTERS Please address each of the following

CASE STUDY: FEDERAL/STATE/LOCAL COLLABORATION NETWORKS IN DISASTERS Please address each of the following questions related to federal-state-local collaboration during disasters.  Support your analysis using peer-reviewed journal articles, textbooks, PowerPoint presentations, and research from textbooks and journals.  Integrate a Biblical perspective within the analysis State the theory first and then apply

Powerpoint assignment 18 to 22 slides on Early literacy books. Who can help? Evaluating Quality Literature and Read-Aloud Experiences for Young

Powerpoint assignment 18 to 22 slides on Early literacy books. Who can help? Evaluating Quality Literature and Read-Aloud Experiences for Young Children Use this template to complete your PowerPoint Presentation on “Evaluating Quality Literature and Read-Aloud Experiences for Young Children.” Add slides as required to provide the specified information and

As a student navigating academic challenges, I found the

As a student navigating academic challenges, I found the <a href=” review</a> to be insightful and informative. It offers a detailed and objective analysis of StudyPool’s services, emphasizing its effectiveness in providing personalized academic support. The review’s discussion on tutor qualifications and responsiveness reassured me of the service’s reliability. It’s

Directions Hospitals and other healthcare settings will often implement Transmission-Based Precautions to prevent or help reduce the spread of

Directions Hospitals and other healthcare settings will often implement Transmission-Based Precautions to prevent or help reduce the spread of infections to healthcare workers, as well other patients in their care. These Transmission-Based Precautions are designed to supplement standard precautions in patients/residents with documented or suspected infection/colonization of highly transmissible or