mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 20:03:16 +01:00
Updated test0 with a forktest. Fixed timeslices. Updated kmem usage calculations.
- test0 now forks 16 tasks that each modify a global variable. - scheduler now gives 1/10th of a second per task. It also does not increase timeslice of a task that has scheduled. - When a memory is granted to the kernel, the distribution of this memory to memcaches was calculated in a complicated way. This is now simplified.
This commit is contained in:
@@ -25,7 +25,6 @@ void init_page_allocator(unsigned long start, unsigned long end);
|
||||
|
||||
/* Page allocation functions */
|
||||
void *alloc_page(int quantity);
|
||||
void *zalloc_page(int quantity);
|
||||
int free_page(void *paddr);
|
||||
|
||||
#endif /* __ALLOC_PAGE_H__ */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define __TASKNAME__ "test0"
|
||||
|
||||
int shmtest(void);
|
||||
int forktest(void);
|
||||
int mmaptest(void);
|
||||
int dirtest(void);
|
||||
int fileio(void);
|
||||
|
||||
@@ -38,13 +38,19 @@ void main(void)
|
||||
printf("Error forking...\n");
|
||||
|
||||
if (pid == 0) {
|
||||
printf("File IO test 1, done by child:\n");
|
||||
printf("Child: file IO test 1.\n");
|
||||
if (fileio() == 0)
|
||||
printf("-- PASSED --\n");
|
||||
else
|
||||
printf("-- FAILED --\n");
|
||||
|
||||
printf("Child: forktest.\n");
|
||||
if (forktest() == 0)
|
||||
printf("-- PASSED -- \n");
|
||||
else
|
||||
printf("-- FAILED -- \n");
|
||||
} else {
|
||||
printf("File IO test 2, done by parent, with child pid %d:\n", pid);
|
||||
printf("Parent: file IO test 2. child pid %d:\n", pid);
|
||||
if (fileio2() == 0)
|
||||
printf("-- PASSED --\n");
|
||||
else
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <tests.h>
|
||||
#include <l4lib/arch/syslib.h>
|
||||
|
||||
int fileio2(void)
|
||||
{
|
||||
@@ -15,10 +14,10 @@ int fileio2(void)
|
||||
int err;
|
||||
char buf[128];
|
||||
off_t offset;
|
||||
int tid = self_tid();
|
||||
|
||||
int tid = getpid();
|
||||
char *str = "I WROTE TO THIS FILE\n";
|
||||
|
||||
memset(buf, 0, 128);
|
||||
if ((fd = open("/home/bahadir/newfile2.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
|
||||
perror("OPEN");
|
||||
return -1;
|
||||
@@ -56,8 +55,12 @@ int fileio2(void)
|
||||
printf("%d: Read: %d bytes from file.\n", tid, cnt);
|
||||
if (cnt) {
|
||||
printf("%d: Read string: %s\n", tid, buf);
|
||||
if (strcmp(buf, str))
|
||||
if (strcmp(buf, str)) {
|
||||
printf("Error: strings not the same:\n");
|
||||
printf("str: %s\n", str);
|
||||
printf("buf: %s\n", buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d: close.\n", tid);
|
||||
@@ -76,10 +79,10 @@ int fileio(void)
|
||||
int err;
|
||||
char buf[128];
|
||||
off_t offset;
|
||||
int tid = self_tid();
|
||||
|
||||
int tid = getpid();
|
||||
char *str = "I WROTE TO THIS FILE\n";
|
||||
|
||||
memset(buf, 0, 128);
|
||||
if ((fd = open("/home/bahadir/newfile.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
|
||||
perror("OPEN");
|
||||
return -1;
|
||||
@@ -106,8 +109,12 @@ int fileio(void)
|
||||
printf("%d: Read: %d bytes from file.\n", tid, cnt);
|
||||
if (cnt) {
|
||||
printf("%d: Read string: %s\n", tid, buf);
|
||||
if (strcmp(buf, str))
|
||||
if (strcmp(buf, str)) {
|
||||
printf("Strings not the same:\n");
|
||||
printf("Str: %s\n", str);
|
||||
printf("Buf: %s\n", buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d: close.\n", tid);
|
||||
@@ -115,7 +122,6 @@ int fileio(void)
|
||||
perror("CLOSE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user