Browse Source

for test

pull/1/head
Rafael Zurita 6 years ago
parent
commit
ae9aa37a94
  1. 4
      README.md
  2. 1
      main/main.c
  3. 3
      system/clkhandler.c
  4. 134
      system/initialize.c
  5. 5
      system/kprintf.c
  6. 10
      system/resched.c

4
README.md

@ -74,7 +74,7 @@ Notes about the port:
4. Max. number of devices (4 to 5)
4. The clkhandler() wakeup() a process (preemption) for CPU every 100ms
5. Several limits for buffers: 32bytes for tty input, 16bytes for names of devices, 1byte for the queues keys, and the list continues
6. sleepms() is now delay sleep100ms()
6. sleepms() is now delay sleep100ms() (and the key for queue "char" in ms * 100)
7. Many vars in data structures have a smaller size (e.g. before:int32, now:char)
8. sleep sleeps max. 20 seconds (date type)
9. most of the libc are from avr-libc
@ -84,6 +84,8 @@ Notes about the port:
13. Most of the const char in source code was moved to FLASH (program space) via __flash directive from gcc, or PROGMEM from avr-libc
14. tty_in is asynchronous (with interrupts) (ok). But tty_out is polled based (synchronous).
15. open, read, write, seek, close use struct dentry. It is on flash on this port
16. remote file systems, local file systems, ram file systems are disabled so far.
17. ports (ptinit, ptsend, ptrecv, etc) are disabled so far.
<a name="douglas"></a>

1
main/main.c

@ -238,6 +238,7 @@ process main(void)
typtr->tyihead = typtr->tyitail = typtr->tyibuff;
semreset(typtr->tyisem, 0);
sleep(10);
len = read(dev, buf, sizeof(buf));

3
system/clkhandler.c

@ -47,7 +47,8 @@ ISR(TIMER0_COMPA_vect)
/* our MCU is slow (16Mhz), so we do resched/preemption every 300ms */
avr_ticks ++;
if (avr_ticks > 300) {
// if (avr_ticks > 300) {
if (avr_ticks > 100) {
avr_ticks=0;
/* Decrement the preemption counter */

134
system/initialize.c

@ -9,23 +9,20 @@
/* avr specific */
#include <avr_serial.h>
#include <avr/pgmspace.h>
// #include <avr/pgmspace.h>
extern void start(void); /* Start of Xinu code */
extern void *_end; /* End of Xinu code */
// extern void start(void); /* Start of Xinu code */
// extern void *_end; /* End of Xinu code */
/* Function prototypes */
extern void main(void); /* Main is the first process created */
extern process shell(void); /* Main is the first process created */
// RAFA
extern process test(void); /* test is the first process created */
static void sysinit(); /* Internal system initialization */
extern void meminit(void); /* Initializes the free memory list */
extern int32 initintc(void);
//extern int32 initintc(void);
//local process startup(void); /* Process to finish startup tasks */
void startup(int, struct procent *); /* Process to finish startup tasks */
/* Declarations of major kernel variables */
@ -58,17 +55,12 @@ pid32 currpid; /* ID of currently executing process */
*/
void nullprocess(void) {
// kprintf("nullp\n");
// resume(create((void *)main, INITSTK, INITPRIO, "Main Process", 0, NULL));
// 200 ok and 400 ok
// resume(create((void *)shell, 400, INITPRIO, "shell", 0, NULL));
//
// // resume(create((void *)main, INITSTK, INITPRIO, "Main Process", 0, NULL));
// // 200 ok and 400 ok
// // resume(create((void *)shell, 400, INITPRIO, "shell", 0, NULL));
resume(create((void *)main, 440, INITPRIO, "main", 0, NULL));
// resume(create((void *)test, 256, INITPRIO, "test", 0, NULL));
//
for(;;);
}
@ -123,38 +115,85 @@ void nulluser()
kprintf("S2:%X\n", *(b+32));
*/
/* Initialize the Null process entry */
int pid = create((void *)nullprocess, INITSTK, 10, "nullp", 0, NULL);
// int pid = create((void *)startup, 64, 10, "start", 0, NULL);
// // resume(create((void *)startup, INITSTK, INITPRIO,
// resume(create((void *)startup, 64, 10,
// "start", 0, NULL));
kprintf("aqui\n");
kprintf("aqui 3\n");
/* Become the Null process (i.e., guarantee that the CPU has */
/* something to run when no other process is ready to execute) */
// /* Initialize the Null process entry */
int pid = create((void *)nullprocess, INITSTK, 10, "nullp", 0, NULL);
//
struct procent * prptr = &proctab[pid];
prptr->prstate = PR_CURR;
//prptr->prstate = PR_READY;
// ready(pid);
// resume(pid);
/* Create a process to finish startup and start main */
//resume(create((void *)startup, INITSTK, INITPRIO,
//resume(create((void *)startup, 256, 10,
// "startup", 0, NULL));
/* Enable interrupts */
enable();
// /* Initialize the real time clock */
// clkinit();
/* Start of nullprocess */
startup(0, prptr);
// resume(create((void *)main, 440, INITPRIO, "main", 0, NULL));
for(;;);
//
// /* Start of nullprocess */
startup(0, prptr);
//
// for(;;);
while (TRUE) {
; /* Do nothing */
}
}
/* Startup does a system call, the processor switches to handler
* mode and prepares for executing the null process (see syscall.c)
* This is also where a kernel mode to user mode switch can
* take place */
/*------------------------------------------------------------------------
*
* startup - Finish startup takss that cannot be run from the Null
* process and then create and resumethe main process
*
*------------------------------------------------------------------------
*/
//local process startup(void)
//{
/* Create a process to execute function main() */
//resume(create((void *)main, INITSTK, INITPRIO,
// "Main process", 0, NULL));
// kprintf("aqui2\n");
//
// resume(create((void *)main, 440, INITPRIO, "main", 0, NULL));
// /* Startup process exits at this point */
//
// return OK;
//}
// /* Startup does a system call, the processor switches to handler
// * mode and prepares for executing the null process (see syscall.c)
// * This is also where a kernel mode to user mode switch can
// * take place */
void startup(int INIT, struct procent *p) {
/* Should not be here, panic */
// resume(INIT);
nullprocess();
//resume(INIT);
avr_kprintf(m6);
panic("");
/* Should not be here, panic */
// resume(INIT);
nullprocess();
//resume(INIT);
avr_kprintf(m6);
panic("");
}
@ -202,6 +241,23 @@ static void sysinit()
prptr->prprio = 0;
}
/* Initialize the Null process entry */
/*
prptr = &proctab[NULLPROC];
prptr->prstate = PR_CURR;
prptr->prprio = 0;
strncpy(prptr->prname, "prnull", 7);
prptr->prstkbase = getstk(NULLSTK);
prptr->prstklen = NULLSTK;
prptr->prstkptr = 0;
currpid = NULLPROC;
*/
// int pid = create((void *)nullprocess, INITSTK, 0, "nullp", 0, NULL);
// struct procent * prptr = &proctab[pid];
// prptr->prstate = PR_CURR;
/* Initialize semaphores */

5
system/kprintf.c

@ -50,10 +50,6 @@ extern void _doprnt(char *, va_list, int (*)(int));
syscall kprintf(char *fmt, ...)
{
va_list ap;
//intmask mask;
//mask = disable();
char output[81];
char *c;
@ -68,6 +64,5 @@ syscall kprintf(char *fmt, ...)
c++;
};
//restore(mask);
return OK;
}

10
system/resched.c

@ -16,28 +16,38 @@ void resched(void) /* Assumes interrupts are disabled */
register struct procent volatile *ptnew; /* Ptr to table entry for new process */
int newpid;
// RAFA
// kprintf("POR ACA\n");
/* If rescheduling is deferred, record attempt and return */
//kprintf("n:%d\n",Defer.ndefers);
if (Defer.ndefers > 0) {
Defer.attempt = TRUE;
return;
}
//kprintf("POR ACA2\n");
/* Point to process table entry for the current (old) process */
////kprintf("cp:%d\n",currpid);
//kprintf("poio:%d\n",ptold->prprio);
//kprintf("read:%d\n", firstkey(readylist));
ptold = (struct pentry *)&proctab[currpid];
if (ptold->prstate == PR_CURR) { /* Process remains eligible */
if (ptold->prprio > firstkey(readylist)) {
//kprintf("POR ACA3\n");
return;
}
//kprintf("POR ACA4\n");
ptold->prstate = PR_READY;
insert(currpid, readylist, ptold->prprio);
}
/* Force context switch to highest priority ready process */
//kprintf("POR ACA5\n");
currpid = dequeue(readylist);
ptnew = &proctab[currpid];
ptnew->prstate = PR_CURR;

Loading…
Cancel
Save