#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

Capstone 2408906454 Design and Analysis of a Simple Computer System Objective:

Capstone 2408906454 Design and Analysis of a Simple Computer System Objective: Students will design, simulate, and analyze the architecture of a simplified computer system, applying concepts from Stephen D. Burd’s materials such as the CPU, memory hierarchy, I/O, and instruction set architecture (ISA). Components: 1. System Design: . CPU Design:

Netbeam offers a range of web development services tailored to boost online presence and brand recognition. They provide custom web development,

Netbeam offers a range of web development services tailored to boost online presence and brand recognition. They provide custom web development, front-end and back-end services, e-commerce platforms, and mobile-optimized solutions. Their expertise spans full-stack development, performance optimization, UX design, API development, and more. Netbeam also emphasizes ongoing customer support and

Neuropsychology Ph.D. program 1. Personal Statement Guidance Statement of

Neuropsychology Ph.D. program 1. Personal Statement Guidance Statement of purpose/statement of academic interest should highlight why you wish to pursue a degree in neuropsychology and address the following: · Describe your academic and research interests, identifying specific faculty member(s) with whom you want to work. · Describe your personal, professional,