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

Module 5 Discussion Class:  DIVERSITY IN ADV HLTH PRACTIC (NUR-505) Caring

Module 5 Discussion Class:  DIVERSITY IN ADV HLTH PRACTIC (NUR-505) Caring for East Indian Hindu, Haitian, & Jewish Populations After studying  Module 5: Lecture Materials & Resources, discuss the following: A. Describe the family structure of some East Indian Hindu families and the effect the family organization may have on

Description ‫المملكة العربية السعودية‬ ‫وزارة التعليم‬ ‫الجامعة السعودية اإللكترونية‬ Kingdom of Saudi Arabia Ministry of Education Saudi

Description ‫المملكة العربية السعودية‬ ‫وزارة التعليم‬ ‫الجامعة السعودية اإللكترونية‬ Kingdom of Saudi Arabia Ministry of Education Saudi Electronic University College of Administrative and Financial Sciences Assignment 3 MGT322 (2nd Term 2023-2024) Deadline: 04/05/2024 @ 23:59 Course Name: Logistics Management Course Code: MGT322 Student’s Name: Semester: 2nd CRN: 24097 Student’s ID

The response to the Boston bombing showed the importance of relationship-building in emergency preparedness. The relationship between the Boston Public

The response to the Boston bombing showed the importance of relationship-building in emergency preparedness. The relationship between the Boston Public Health Commission and Walgreen’s epitomizes the importance of public-private sector cooperation and how it pays off during an emergency. Research a large-scale event in the U.S and describe existing public-private

please see attachment Health Concepts HLTH185 Chapter 5 Developing Muscular Strength and Endurance and Chapter 6 Flexibility Name

please see attachment Health Concepts HLTH185 Chapter 5 Developing Muscular Strength and Endurance and Chapter 6 Flexibility Name ___________________________________ Date _____________________________ For this activity, you will apply concepts from the chapters on “Developing Muscular Strength and Endurance” and “Flexibility”. You will develop a Muscular strength, endurance, and flexibility program for