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

Description Over the next decade, the global business environment will experience significant changes driven by technological advancements,

Description Over the next decade, the global business environment will experience significant changes driven by technological advancements, shifting economic powers, and changing consumer preferences. The rapid development of technologies such as artificial intelligence (AI), machine learning, blockchain, and the Internet of Things (IoT) will continue to disrupt industries, improving efficiency,

The Current Conflict within the Mass Deportation of Afghans in Pakistan Work detailsAttached filesWork resultsRevisionsType of paperResearch

The Current Conflict within the Mass Deportation of Afghans in Pakistan Work detailsAttached filesWork resultsRevisionsType of paperResearch PaperSubjectOtherNumber of pages4Format of citationAPA 7Number of cited resources3Type of serviceWritingSpacingDouble (1200 words)1.Talk about culture or group. 2. Add a current conflict within the culture or group. 3. And how as a social

Description I kindly need your support with the following question: Towards a Conceptual Framework  In this module you have examined the different

Description I kindly need your support with the following question: Towards a Conceptual Framework  In this module you have examined the different types of change management frameworks. Now read, Rethinking organizational change: Towards a conceptual framework from  the required reading list. This study proposes a conceptual framework  incorporating the macro

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 1 Marketing Management (MGT 201) Due Date: 13/07/2024 @ 23:59 Course Name: Marketing Management Student’s Name: Course Code: MGT 201 Student’s ID Number: Semester: