Mon 14 Oct 23:09:15 CEST 2024

This commit is contained in:
sbosse 2024-10-14 23:09:49 +02:00
parent 54f272ddb4
commit 387929d599

42
user/test/test.c Normal file
View File

@ -0,0 +1,42 @@
/*
Copyright (C) 2016-2019 The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file LICENSE for details.
*/
#include "library/syscalls.h"
#include "library/string.h"
#include "library/malloc.h"
int main(int argc, char *argv[])
{
printf("hello world, I am %d, and I have %d arguments!\n", syscall_process_self(), argc);
printf("They are: ");
int i;
for(i = 0; i < argc; ++i) {
printf("(%s) ", argv[i]);
}
printf("\n");
int n = 4096;
printf("adding up %d values...\n", n);
int *big = malloc(n * sizeof(int));
if(!big)
printf("malloc failed!\n");
for(i = 0; i < n; i++) {
big[i] = i;
}
int sum = 0;
for(i = 0; i < n; ++i) {
sum += big[i];
}
free(big);
printf("The sum of 0 to %d is %d\n", n, sum);
return 0;
}