[Linux-hls-cvs] hls/simul Makefile,1.9,1.10 sim.c,1.7,1.8 sim_cpu.c,1.9,1.10 sim_events.c,1.11,1.12
Status: Pre-Alpha
Brought to you by:
lucabe
|
From: <lu...@us...> - 2003-02-10 16:24:26
|
Update of /cvsroot/linux-hls/hls/simul
In directory sc8-pr-cvs1:/tmp/cvs-serv20402/simul
Modified Files:
Makefile sim.c sim_cpu.c sim_events.c sim_os.c workload.c
Log Message:
- Some work in the workload generator
- New docs directory + doc about my power management proposal
Index: Makefile
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/Makefile,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Makefile 13 Dec 2002 11:26:12 -0000 1.9
--- Makefile 10 Feb 2003 16:23:45 -0000 1.10
***************
*** 8,14 ****
#CPPFLAGS += -DVERBOSE
! DEBUG = -lefence
CFLAGS += -g
! CPPFLAGS += -DHLS_DEBUG=0
all: simulator
--- 8,15 ----
#CPPFLAGS += -DVERBOSE
! #DEBUG = -lefence
CFLAGS += -g
! CPPFLAGS += -DHLS_DEBUG=10
! CPPFLAGS += -D__SIM_VERBOSE__
all: simulator
Index: sim.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** sim.c 17 Oct 2002 08:21:42 -0000 1.7
--- sim.c 10 Feb 2003 16:23:45 -0000 1.8
***************
*** 85,88 ****
--- 85,89 ----
int finished;
+ printf("Blah!\n");
switch (argc) {
case 2:
Index: sim_cpu.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim_cpu.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** sim_cpu.c 25 Nov 2002 11:33:32 -0000 1.9
--- sim_cpu.c 10 Feb 2003 16:23:45 -0000 1.10
***************
*** 30,34 ****
thread_init();
for (i=0; i < NR_CPUS; i++) {
! processors[i].idle.pid = -i;
processors[i].idle.sim_state = THREAD_SM_NEVERENDING;
}
--- 30,34 ----
thread_init();
for (i=0; i < NR_CPUS; i++) {
! processors[i].idle.pid = -1 -i;
processors[i].idle.sim_state = THREAD_SM_NEVERENDING;
}
***************
*** 77,89 ****
long long int sim_time = sim_get_time();
if (ot) {
! fprintf(outfile, "%s\t\t%lld %lld\n", ThreadStr(ot),
! processors[proc].dispatch_time, sim_time);
if (ot != &processors[proc].idle) {
! ot->total_remaining_cpu_time -= (sim_time - processors[proc].dispatch_time);
! ot->time_until_blocking -= (sim_time - processors[proc].dispatch_time);
sim_printf("[%d] ---> %lld\t", ot->pid, ot->total_remaining_cpu_time);
! sim_printf("(bt) ---> %lld\n", ot->time_until_blocking);
}
}
--- 77,95 ----
long long int sim_time = sim_get_time();
+ sim_printf("Start Running Thread\n");
if (ot) {
! fprintf(outfile, "%s\t\t%lld %lld\t\t%lld\n", ThreadStr(ot),
! processors[proc].dispatch_time, sim_time,
! sim_time - processors[proc].dispatch_time);
if (ot != &processors[proc].idle) {
! if (ot->total_remaining_cpu_time != -1) {
! ot->total_remaining_cpu_time -= (sim_time - processors[proc].dispatch_time);
! }
! if (ot->ci != -1) {
! ot->ci -= (sim_time - processors[proc].dispatch_time);
! }
sim_printf("[%d] ---> %lld\t", ot->pid, ot->total_remaining_cpu_time);
! sim_printf("(bt) ---> %lld\n", ot->ci);
}
}
Index: sim_events.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim_events.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** sim_events.c 13 Dec 2002 11:26:12 -0000 1.11
--- sim_events.c 10 Feb 2003 16:23:45 -0000 1.12
***************
*** 10,14 ****
/* TODO: Check all of these!!! */
- long long int max_run_time_until_blocking;
long long int max_blocking_time;
long long int max_res_time;
--- 10,13 ----
***************
*** 87,90 ****
--- 86,90 ----
{
struct sim_event *e;
+ long long int max_time_until_quit;
sim_printf("seed = %u\n", seed);
***************
*** 99,103 ****
! workload_generate();
/*
* first timer interrupt - each interrupt puts in the next one
--- 99,103 ----
! max_time_until_quit = workload_generate();
/*
* first timer interrupt - each interrupt puts in the next one
***************
*** 107,110 ****
--- 107,113 ----
insert_event(e, (long long int)time_increment);
+ e = new_event(EVENT_TYPE_SHUTDOWN, sim_rand() % sim_nr_cpus());
+ e->u.event_thread.t = NULL;
+ insert_event(e, sim_rand() % max_time_until_quit);
}
***************
*** 144,152 ****
}
- #if 1
void next_task_event(int proc, struct sim_task_struct *ot, struct sim_task_struct *nt, long long int sim_time)
{
if (ot != NULL) {
if ((ot->sim_state != THREAD_SM_ENDED) && (ot->sim_state != THREAD_SM_NEVERENDING)) {
sim_printf("removing end...\n");
event_list_remove(&end_e);
--- 147,158 ----
}
void next_task_event(int proc, struct sim_task_struct *ot, struct sim_task_struct *nt, long long int sim_time)
{
if (ot != NULL) {
+ sim_printf("Next Task Event: sim_state = %d total_remaining_cpu_time = %d\n", ot->sim_state, ot->total_remaining_cpu_time);
+ #if 0
if ((ot->sim_state != THREAD_SM_ENDED) && (ot->sim_state != THREAD_SM_NEVERENDING)) {
+ #endif
+ if ((ot->sim_state != THREAD_SM_ENDED) && (ot->total_remaining_cpu_time != -1)) {
sim_printf("removing end...\n");
event_list_remove(&end_e);
***************
*** 158,197 ****
}
! if (nt->kind == BLOCKING) {
! block_e.proc = proc;
! block_e.u.event_thread.t = nt;
sim_printf("posting the block event for %d at %lld = %lld + %lld\n",
! nt->pid, nt->time_until_blocking + sim_time,
! nt->time_until_blocking, sim_time);
! insert_event(&block_e, nt->time_until_blocking + sim_time);
! }
! if (nt->sim_state != THREAD_SM_NEVERENDING) {
! end_e.proc = proc;
! end_e.u.event_thread.t = nt;
! insert_event(&end_e, nt->total_remaining_cpu_time + sim_time);
}
}
- #else
- void next_task_event(int proc, struct sim_task_struct *nt, long long int sim_time)
- {
- struct sim_event *e;
- /*
- * fire an event at the nearest time that we could possibly care
- * about
- */
- e = new_event(EVENT_TYPE_THREAD_EVENT, proc);
- e->u.event_thread.t = nt;
- sim_printf("%lld --- ", sim_time);
- sim_printf("%d, kind:%d) remaining: %lld\tBlocking: %lld\tReady: %lld\n",
- nt->pid, nt->kind,
- sim_time + nt->total_remaining_cpu_time,
- sim_time + nt->time_until_blocking,
- nt->ready_time);
- sim_printf("real... %lld %lld\n", nt->total_remaining_cpu_time,nt->time_until_blocking);
- insert_event(e, min(sim_time + nt->total_remaining_cpu_time,
- (nt->sim_state == THREAD_SM_READY) ?
- sim_time + nt->time_until_blocking : nt->ready_time));
- }
- #endif
static int DoEventSetPri(struct sim_event *ev, long long int time)
--- 164,184 ----
}
! if (nt->pid >= 0) {
! if (nt->kind == BLOCKING) {
! block_e.proc = proc;
! block_e.u.event_thread.t = nt;
sim_printf("posting the block event for %d at %lld = %lld + %lld\n",
! nt->pid, nt->ci + sim_time,
! nt->ci, sim_time);
! insert_event(&block_e, nt->ci + sim_time);
! }
! /* if (nt->sim_state != THREAD_SM_NEVERENDING) {*/
! if (nt->total_remaining_cpu_time != -1) {
! end_e.proc = proc;
! end_e.u.event_thread.t = nt;
! insert_event(&end_e, nt->total_remaining_cpu_time + sim_time);
! }
}
}
static int DoEventSetPri(struct sim_event *ev, long long int time)
***************
*** 222,226 ****
t->sim_state = THREAD_SM_BLOCKED;
! t->ready_time = time + (sim_rand() % max_blocking_time) + 10;
t->state = TASK_INTERRUPTIBLE;
e = new_event(EVENT_TYPE_THREAD_UNBLOCK, (PROCT)sim_rand() % sim_nr_cpus());
--- 209,214 ----
t->sim_state = THREAD_SM_BLOCKED;
! /* t->ready_time = time + (sim_rand() % max_blocking_time) + 10;*/
! t->ready_time = t->ready_time + t->iat();
t->state = TASK_INTERRUPTIBLE;
e = new_event(EVENT_TYPE_THREAD_UNBLOCK, (PROCT)sim_rand() % sim_nr_cpus());
***************
*** 248,254 ****
t->sim_state = THREAD_SM_READY;
if (t->kind == BLOCKING) {
! t->time_until_blocking = (sim_rand() % max_run_time_until_blocking) + 10;
} else {
! t->time_until_blocking = t->total_remaining_cpu_time;
}
thread_unblock(t);
--- 236,242 ----
t->sim_state = THREAD_SM_READY;
if (t->kind == BLOCKING) {
! t->ci = t->c();
} else {
! t->ci = -1;
}
thread_unblock(t);
***************
*** 281,285 ****
if (t->ready_time == time) {
t->sim_state = THREAD_SM_READY;
! t->time_until_blocking = (sim_rand() % max_run_time_until_blocking) + 10;
thread_unblock(t);
} else {
--- 269,273 ----
if (t->ready_time == time) {
t->sim_state = THREAD_SM_READY;
! t->ci = t->c();
thread_unblock(t);
} else {
***************
*** 300,303 ****
--- 288,292 ----
if (t->sim_state != THREAD_SM_READY) {
+ printf("End Task %s\n", ThreadStr(t));
printf("Error: End task with state = %d != THREAD_SM_READY\n",
t->sim_state);
***************
*** 321,325 ****
printf("End: There is a problem...\n");
printf("Kind = %d, time_until_blocking = %lld, exec_time = %lld\n",
! t->kind, t->time_until_blocking, exec_time);
exit(-1);
}
--- 310,314 ----
printf("End: There is a problem...\n");
printf("Kind = %d, time_until_blocking = %lld, exec_time = %lld\n",
! t->kind, t->ci, exec_time);
exit(-1);
}
***************
*** 352,356 ****
exec_time = time - sim_dispatch_time(SIMCurrentProc);
! if (t->time_until_blocking - exec_time == 0) {
schedule_unblock(t, time); /* Sets the unblocking event... */
thread_block(t);
--- 341,345 ----
exec_time = time - sim_dispatch_time(SIMCurrentProc);
! if (t->ci - exec_time == 0) {
schedule_unblock(t, time); /* Sets the unblocking event... */
thread_block(t);
***************
*** 358,362 ****
printf("[%d] There is a problem...\n", t->pid);
printf("Kind = %d, time_until_blocking = %lld, exec_time = %lld\n",
! t->kind, t->time_until_blocking, exec_time);
exit(-1);
}
--- 347,351 ----
printf("[%d] There is a problem...\n", t->pid);
printf("Kind = %d, time_until_blocking = %lld, exec_time = %lld\n",
! t->kind, t->ci, exec_time);
exit(-1);
}
***************
*** 365,438 ****
}
- #if 0
- static int DoEventThreadEvent(struct sim_evet *ev, long long int time)
- {
- long long int exec_time;
- struct sim_task_struct *t;
-
- t = ev->u.event_thread.t;
-
- sim_printf("(sim) executing thread event for %s (%p) at time %lld\n",
- thread_name(t), t, time);
-
-
-
-
-
-
-
-
- switch (t->sim_state) {
- case THREAD_SM_BLOCKED:
- if (t->ready_time == time) {
- t->sim_state = THREAD_SM_READY;
- if (t->kind == BLOCKING) {
- t->time_until_blocking = (sim_rand() % max_run_time_until_blocking) + 10;
- }
- thread_unblock(t);
- } else {
- /* FIXME: how can this happen? when addresses are reused?? */
- printf("sim is confused: got event for blocked thread %s (%p) at wrong time: %lld\n",
- thread_name(t), t, time);
- exit(-1);
- }
- break;
-
- case THREAD_SM_READY:
- if (sim_exec(SIMCurrentProc) != t) {
- break;
- }
-
- exec_time = time - sim_dispatch_time(SIMCurrentProc);
- if (t->total_remaining_cpu_time - exec_time == 0) {
- thread_end(t, time);
- } else {
- if (t->kind == BLOCKING && t->time_until_blocking - exec_time == 0) {
- sim_printf("Blocking thread %d\n", t->pid);
- schedule_unblock(t, time);
- thread_block(t);
- /* swap_thread(); Not Needed */
- } else {
- printf("There is a problem...\n");
- printf("Kind = %d, time_until_blocking = %d, exec_time = %d\n",
- t->kind, t->time_until_blocking, exec_time);
- /* We do not exit here, because, if there is a context
- * switch the event should be removed, but it is not...
- * so, a strange event fires
- * exit(-1);
- */
- }
- }
- break;
-
- default:
- printf("Error! Strange simulation state: %d\n", t->sim_state);
- exit(-1);
- }
-
- return 0;
- }
- #endif
-
static int DoEventInitialize(struct sim_event *e, long long int time)
{
--- 354,357 ----
***************
*** 502,506 ****
}
- #if 1
static int DoEventIdleLoop(struct sim_event *ev, long long int time)
{
--- 421,424 ----
***************
*** 509,559 ****
return 0;
}
- #else
- static int DoEventIdleLoop(void)
- {
- int res;
- /* PKPRCB p = KeGetCurrentPrcb (); */
-
- if (sim_exec(SIMCurrentProc) == NULL) {
- printf("Exec = NULL???\n");
- }
- if (sim_exec(SIMCurrentProc) != sim_idle_thread(SIMCurrentProc)) {
- printf("idle thread not running now\n");
-
- return;
- }
-
- /* simulate not getting the dispatcher lock ??? */
- if (sim_rand() % 1000 < 300) goto out;
-
- res = HLSCheckFromIdle();
-
- if (res != 0) {
- goto jump_into_middle;
- }
-
- if (!p->NextThread) {
- goto out;
- }
-
- KeAcquireQueuedSpinLockRaiseToSynch(LockQueueDispatcherLock); //lint !e534
-
- jump_into_middle:
-
- start_running_thread(p->CurrentThread, p->NextThread);
- p->CurrentThread = p->NextThread;
- p->CurrentThread->State = Running;
- p->NextThread = NULL;
-
- #ifdef HLS_DEBUG
- HLSCheckInvariants (('F' << 16) | FROM_UNLOCK);
- #endif
- KeReleaseQueuedSpinLock (LockQueueDispatcherLock, SAVED_IRQL);
-
- out:
-
- check_for_idle (p->Number);
- }
- #endif
static int DoEventNewProc(struct sim_event *ev, long long int time)
--- 427,430 ----
Index: sim_os.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim_os.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** sim_os.c 13 Dec 2002 11:26:12 -0000 1.6
--- sim_os.c 10 Feb 2003 16:23:46 -0000 1.7
***************
*** 17,24 ****
/*
extern long long int max_res_time;
- extern long long int max_run_time_until_blocking;
extern long long int cpu_time_per_thread;
*/
- extern long long int max_time_until_quit;
extern int res_number;
--- 17,22 ----
***************
*** 94,98 ****
struct sim_task_struct *make_new_thread(long long int create_time,
! long long int cpu_time, long long int job_exec_time, int prio)
{
int id = sim_new_id();
--- 92,98 ----
struct sim_task_struct *make_new_thread(long long int create_time,
! long long int cpu_time, long long int (*job_exec_time)(void),
! long long int (*job_interarrival_time)(void),
! int prio)
{
int id = sim_new_id();
***************
*** 114,120 ****
sim_thread_count++;
!
! /* FIXME: From here on, it does not belong to make_new_thread... */
! t->total_desired_cpu_time = t->total_remaining_cpu_time = cpu_time;
#if 0 /* FIXME: Move this reserve stuff elsewhere... */
if (res_number++ < NUM_RSV) {
--- 114,122 ----
sim_thread_count++;
! if (cpu_time != 0) {
! t->total_desired_cpu_time = t->total_remaining_cpu_time = cpu_time;
! } else {
! t->total_desired_cpu_time = t->total_remaining_cpu_time = -1;
! }
#if 0 /* FIXME: Move this reserve stuff elsewhere... */
if (res_number++ < NUM_RSV) {
***************
*** 126,138 ****
#endif
! if (job_exec_time == 0) { // FIXME
t->kind = CPUBOUND;
! t->time_until_blocking = t->total_remaining_cpu_time;
sim_printf("Task %d is cpu bound: %lld\t%lld\n", t->pid,
t->total_desired_cpu_time,
! t->time_until_blocking);
} else {
t->kind = BLOCKING;
! t->time_until_blocking = sim_rand() % job_exec_time;
}
--- 128,147 ----
#endif
! t->iat = job_interarrival_time;
! if (job_exec_time == NULL) { // FIXME
t->kind = CPUBOUND;
! t->ci = t->total_remaining_cpu_time;
sim_printf("Task %d is cpu bound: %lld\t%lld\n", t->pid,
t->total_desired_cpu_time,
! t->ci);
! t->c = NULL;
} else {
t->kind = BLOCKING;
! t->ci = job_exec_time();
! if (t->iat == NULL) {
! sim_printf("Error: blocking job with IAT = NULL!!!\n");
! exit(-1);
! }
! t->c = job_exec_time;
}
***************
*** 178,186 ****
// make_new_thread(time + 1 + (sim_rand() % 100000));
sim_thread_count--;
- if (sim_thread_count == 0) {
- e = new_event(EVENT_TYPE_SHUTDOWN, sim_rand() % sim_nr_cpus());
- e->u.event_thread.t = t;
- insert_event(e, time + 1 + (sim_rand() % max_time_until_quit));
- }
/* swap_thread(); Not Needed */
}
--- 187,190 ----
Index: workload.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/workload.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** workload.c 13 Dec 2002 11:26:12 -0000 1.1
--- workload.c 10 Feb 2003 16:23:47 -0000 1.2
***************
*** 11,60 ****
- static long long int MAX_TIME_UNTIL_DISPATCH_INTERRUPT;
- static long long int MAX_TIME_UNTIL_IDLE_CHECK;
-
int total_num_threads;
- long long int max_time_until_quit;
extern long long int max_res_time;
- extern long long int max_run_time_until_blocking;
extern long long int cpu_time_per_thread;
extern long long int max_blocking_time;
! void workload_generate(void)
{
int EndNumProcessors;
! int NUM_THREADS;
int i;
- #if 0
- EndNumProcessors = (sim_rand() % 3) + 3;
- #else
EndNumProcessors = 1;
! #endif
! NUM_THREADS = (sim_rand() % 25) + 250;
! total_num_threads = 10 + (sim_rand() % 30);
! /*
! sim_printf ("simulating %d processors and %d threads\n",
! EndNumProcessors, NUM_THREADS);
! */
! sim_printf ("simulating %d threads\n", NUM_THREADS);
! // FIXME: make the simulator create and destroy lots of threads
! // have a max num of threads and create more when current is
! // less than this
!
! max_run_time_until_blocking = ((long long int)(sim_rand()%1000000))+500;
max_blocking_time = ((long long int)(sim_rand()%100000))+500;
- max_time_until_quit = ((long long int)(sim_rand()%10000));
- MAX_TIME_UNTIL_DISPATCH_INTERRUPT = (sim_rand()%50000)+50;
- MAX_TIME_UNTIL_IDLE_CHECK = (sim_rand()%50000)+50;
max_res_time = 100000000;
cpu_time_per_thread = /*HLS_MsToNT * 500*/ /*1000000*/ 500000;
!
! for(i = 0; i < NUM_THREADS; i++) {
! make_new_thread((long long int)((sim_rand() % 10000) + 1000), cpu_time_per_thread, /* max_run_time_until_blocking */0,
! TH_FIXED_PRIO);
}
--- 11,51 ----
int total_num_threads;
extern long long int max_res_time;
extern long long int cpu_time_per_thread;
extern long long int max_blocking_time;
! long long int execution_time(void)
! {
! return 2000000;
! }
!
! long long int period(void)
! {
! return 100000000;
! }
!
! long long int workload_generate(void)
{
int EndNumProcessors;
! int threads;
int i;
EndNumProcessors = 1;
!
! threads = 10;
! total_num_threads = 20;
! sim_printf("simulating %d threads\n", threads);
! #if 0
max_blocking_time = ((long long int)(sim_rand()%100000))+500;
max_res_time = 100000000;
cpu_time_per_thread = /*HLS_MsToNT * 500*/ /*1000000*/ 500000;
! #endif
!
! for(i = 0; i < threads; i++) {
! make_new_thread(100, 0, execution_time, period, TH_FIXED_PRIO);
}
***************
*** 81,83 ****
--- 72,75 ----
#endif
+ return 1000000000;
}
|