2 * Copyright (c) 2009 The Regents of the University of California
3 * Barret Rhoden <brho@cs.berkeley.edu>
4 * See LICENSE for details.
12 #include <ros/common.h>
14 #include <arch/init.h>
31 #include <colored_caches.h>
36 * Currently, if you leave this function by way of proc_run (process_workqueue
37 * that proc_runs), you will never come back to where you left off, and the
38 * function will start from the top. Hence the hack 'progress'.
42 #ifndef DEVELOPER_NAME
43 #define DEVELOPER_NAME brho
47 #define PASTE(s1,s2) s1 ## s2
48 #define MANAGER_FUNC(dev) PASTE(manager_,dev)
50 void MANAGER_FUNC(DEVELOPER_NAME)(void);
51 MANAGER_FUNC(DEVELOPER_NAME)();
54 void manager_brho(void)
56 static uint8_t RACY progress = 0;
58 static struct proc *envs[256];
59 static struct proc *p ;
61 // for testing taking cores, check in case 1 for usage
62 uint32_t corelist[MAX_NUM_CPUS];
67 // TODO: need to store the pid for future manager runs, not the *p
68 p = kfs_proc_create(kfs_lookup_path("pthread_test"));
69 //p = kfs_proc_create(kfs_lookup_path("mhello"));
70 //p = kfs_proc_create(kfs_lookup_path("roslib_mhello"));
71 //p = kfs_proc_create(kfs_lookup_path("roslib_mproctests"));
72 //p = kfs_proc_create(kfs_lookup_path("roslib_spawn"));
73 // being proper and all:
74 spin_lock(&p->proc_lock);
75 __proc_set_state(p, PROC_RUNNABLE_S);
76 // normal single-cored way
77 spin_unlock(&p->proc_lock);
81 // this is how you can transition to a parallel process manually
82 // make sure you don't proc run first
83 __proc_set_state(p, PROC_RUNNING_S);
84 __proc_set_state(p, PROC_RUNNABLE_M);
85 p->resources[RES_CORES].amt_wanted = 5;
86 spin_unlock(&p->proc_lock);
88 panic("This is okay");
95 // this is a ghetto way to test restarting an _M
96 printk("\nattempting to ghetto preempt...\n");
97 spin_lock(&p->proc_lock);
98 proc_take_allcores(p, __death);
99 __proc_set_state(p, PROC_RUNNABLE_M);
100 spin_unlock(&p->proc_lock);
102 printk("\nattempting to restart...\n");
103 core_request(p); // proc still wants the cores
104 panic("This is okay");
105 // this tests taking some cores, and later killing an _M
106 printk("taking 3 cores from p\n");
107 for (int i = 0; i < num; i++)
108 corelist[i] = 7-i; // 7, 6, and 5
109 spin_lock(&p->proc_lock);
110 proc_take_cores(p, corelist, &num, __death);
111 spin_unlock(&p->proc_lock);
113 printk("Killing p\n");
115 printk("Killed p\n");
116 panic("This is okay");
118 envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
119 __proc_set_state(envs[0], PROC_RUNNABLE_S);
125 test_smp_call_functions();
129 test_lapic_status_bit();
134 printd("Manager Progress: %d\n", progress);
135 // delay if you want to test rescheduling an MCP that yielded
139 panic("If you see me, then you probably screwed up");
142 printk("Servicing syscalls from Core 0:\n\n");
144 process_generic_syscalls(&envs[0], 1);
151 void manager_klueska()
153 static struct proc *envs[256];
154 static volatile uint8_t progress = 0;
158 envs[0] = kfs_proc_create(kfs_lookup_path("fillmeup"));
159 __proc_set_state(envs[0], PROC_RUNNABLE_S);
164 panic("DON'T PANIC");
176 void manager_waterman()
182 struct proc* p = proc_create(NULL,0);
184 char* argv[] = {"/bin/sh","-l",0};
185 char* envp[] = {"LD_LIBRARY_PATH=/lib",0};
186 procinfo_pack_args(p->procinfo,argv,envp);
188 struct file* f = file_open("/bin/busybox",0,0);
190 assert(load_elf(p,f) == 0);
193 __proc_set_state(p, PROC_RUNNABLE_S);
199 void manager_pearce()
201 static struct proc *envs[256];
202 static volatile uint8_t progress = 0;
206 envs[0] = kfs_proc_create(kfs_lookup_path("parlib_httpserver_integrated"));
207 //envs[0] = kfs_proc_create(kfs_lookup_path("parlib_lock_test"));
208 __proc_set_state(envs[0], PROC_RUNNABLE_S);
213 panic("DON'T PANIC");
221 itoa(int num, char* buf0, size_t base)
236 buf[len++] = "0123456789abcdef"[num%base];
240 for(i = 0; i < len/2; i++)
243 buf[i] = buf[len-i-1];
251 void gsf_set_frame_cycles(int cycles)
253 store_alternate(26*4,2,cycles);
256 void gsf_set_partition_credits(int partition, int credits)
258 store_alternate((32+partition)*4,2,credits);
261 void gsf_set_core_partition(int core, int partition)
263 store_alternate((64+core)*4,2,partition);