/demos/tags/rel_1_4_rc1/loader/generators/java/java_gen |
File deleted |
|
Property changes: |
Deleted: svn:executable |
## -1 +0,0 ## |
-* |
\ No newline at end of property |
Index: tags/rel_1_4_rc1/loader/generators/java/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/java/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/java/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-ifdef CLASSPATH |
-all: |
- javac Application.java timespec.java task_class.java -classpath "$(CLASSPATH)/jdom.jar" |
-else |
-all: |
- @echo ---------------------------------------------------------------- |
- @echo Please define the CLASSPATH environment variable!!! |
- @echo ...something like: export CLASSPATH=/usr/java/j2sdk1.4.2/jre/lib |
- @echo ---------------------------------------------------------------- |
- @exit 1 |
-endif |
- |
- |
-clean: |
- rm -f *.class |
- rm -f event.c |
- |
Index: tags/rel_1_4_rc1/loader/generators/java/Application.java |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/java/Application.java (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/java/Application.java (nonexistent) |
@@ -1,856 +0,0 @@ |
-//package first_filter; |
- |
-import java.io.*; |
-import java.net.*; |
-import java.util.List; |
-import java.util.ArrayList; |
-import java.util.Iterator; |
-import org.jdom.*; |
-import org.jdom.input.SAXBuilder; |
-import org.jdom.output.XMLOutputter; |
-import java.util.regex.*; |
-import java.util.Random; |
- |
-/** |
- * <p>Title: First XML filter</p> |
- * <p>Description: </p> |
- * <p>Copyright: Copyright (c) 2003</p> |
- * <p>Company: Retis Lab</p> |
- * @author not attributable |
- * @version 1.0 |
- */ |
- |
-public class Application { |
- private int numElements = 0; |
- final String LOADFILE_DIR="../loadfile/"; |
- final String EVENT_DEFINE="event.c"; |
- final String ACT_LIST="event.c"; |
- private int servernumber=0; |
- private timespec simulation_time=new timespec(); |
- ArrayList local_scheduler=new ArrayList(); |
- ArrayList Task_Section=new ArrayList(); |
- private int task_group=0; |
- private int task_server=0; |
- private int current_scheduler=0; |
- |
- |
- |
- //Construct the frame |
- public Application() { |
- try { |
- jbInit(); |
- } |
- catch(Exception e) { |
- e.printStackTrace(); |
- } |
- } |
- //Component initialization |
- private void jbInit() throws Exception { |
- } |
- |
- public void process (String url) throws MalformedURLException { |
- try { |
- // Use SAXBuilder |
- SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true); |
- builder.setFeature("http://apache.org/xml/features/validation/schema", true); |
- |
- |
- Document doc = builder.build(url); |
- Element root = doc.getRootElement(); |
- |
- try { |
- // Funzione per il salvataggio del file XML |
- OutputStream fout = new FileOutputStream(EVENT_DEFINE); |
- OutputStream bout = new BufferedOutputStream(fout); |
- OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1"); |
- out.write("\n#include \"func.h\"\n"); |
- |
- processElement (root,out); |
- out.flush(); |
- out.close(); |
- } catch (UnsupportedEncodingException e) { |
- System.out.println("Non sono supportati i caratteri latini"); |
- System.exit(1); |
- |
- } catch (IOException e){ |
- System.out.println("Salvatagio fallito"); |
- System.exit(1); |
- } |
- |
- |
- |
- System.out.println ("Total Number of Elements Processed: " |
- +numElements); |
- } catch (JDOMException e) { |
- System.out.println ("JDOM Exception: "+e.getMessage()); |
- } catch (java.io.IOException e) { |
- System.out.println ("File Exception: "+e.getMessage()); |
- |
- } |
-} |
- |
-// Recursive Function to Process Elements |
-// Prints the Element Name and keeps a running count |
-// out total number of elements. |
-private void processElement(Element element, OutputStreamWriter out) { |
- numElements++; |
- String elementName = element.getName(); |
- |
- System.out.println(elementName); |
- List servers = element.getChildren(); |
- Iterator iterator = servers.iterator(); |
- /* get simulation parameter */ |
- Element SimulationInfo = (Element) iterator.next(); |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- try { |
- /*simulation time */ |
- |
- String[] stime = pattern.split(SimulationInfo.getChild("time").getText()); |
- out.write("struct timespec total_time={" + stime[0] + "," + stime[1] + |
- "};\n\n"); |
- simulation_time.tv_sec = Long.valueOf(stime[0].trim()).longValue(); |
- simulation_time.tv_nsec = Long.valueOf(stime[1].trim()).longValue() / |
- 1000; |
-//float f = Float.valueOf(s.trim()).floatValue(); |
- /* server section start */ |
- out.write("struct loader_contract loader_contract_list[] = {\n"); |
- int total_server=0; |
- while (iterator.hasNext()) { |
- /* get server */ |
- Element server = (Element) iterator.next(); |
- process_server_section(server, out); |
- total_server++; |
- } |
- |
- out.write("};\n\n"); |
- |
- out.write("int total_loader_contract="+total_server+";\n\n"); |
- iterator = local_scheduler.iterator(); |
- while (iterator.hasNext()) { |
- /* get server */ |
- Element loc_sched = (Element) iterator.next(); |
- process_scheduler_section(loc_sched, out); |
- task_server++; |
- } |
- |
- iterator = Task_Section.iterator(); |
- int total_task_section=0; |
- out.write("\nstruct loader_task loader_task_list[] = {\n"); |
- while (iterator.hasNext()) { |
- /* get server */ |
- task_class tsk_sec = (task_class) iterator.next(); |
- out.write(" {\"" + tsk_sec.name + "\"," + tsk_sec.task_type + "," + |
- tsk_sec.contract + |
- "," + tsk_sec.localscheduler + "," + tsk_sec.number + "," |
- + tsk_sec.group + ",{" + tsk_sec.deadline.tv_sec + |
- "," + |
- tsk_sec.deadline.tv_nsec + "}," + "{" + |
- tsk_sec.wcet.tv_sec + "," + |
- tsk_sec.wcet.tv_nsec + "}," + tsk_sec.act_number + |
- ",0,act_" + tsk_sec.name + |
- ",exec_" + tsk_sec.name + "},\n"); |
- total_task_section++; |
- } |
- out.write("};\n\n"); |
- out.write("int total_loader_task="+total_task_section+";\n\n"); |
- |
- |
- } |
- catch (java.io.IOException e) { |
- System.out.println("File Exception: " + e.getMessage()); |
- |
- } |
- |
-} |
- |
-void process_scheduler_section(Element e, OutputStreamWriter out) { |
- Attribute t; |
- t=e.getAttribute("type"); |
- |
- List localpars = e.getChildren(); |
- Iterator iterator = localpars.iterator(); |
- while (iterator.hasNext()) { |
- /* get task section */ |
- Element loc_task = (Element) iterator.next(); |
- process_task_section(loc_task, out, t); |
- |
- } |
- |
-} |
- |
-void process_task_section(Element e, OutputStreamWriter out, Attribute loc) { |
- Attribute t; |
- int act; |
- act=1; |
- int task_type=0; |
- int localscheduler=0; |
- timespec time = new timespec(); |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- String scheduler=loc.getValue(); |
- if (scheduler.equals("POSIX")) { |
- localscheduler=30; |
- } |
- else if (scheduler.equals("EDF")) { |
- localscheduler=31; |
- } |
- else if (scheduler.equals("RM")) { |
- localscheduler=32; |
- } |
- |
- /* get task section */ |
- t=e.getAttribute("type"); |
- |
- if (t.getValue().equals("BackTask")) { |
- process_back_task(e, out); |
- task_type=23; |
- } else if (t.getValue().equals("OneShot")) { |
- process_oneshot_task(e, out); |
- task_type=21; |
- } else if (t.getValue().equals("CyclicalTask")) { |
- task_type=22; |
- act=process_cyclical_task(e, out); |
- } |
- |
- task_class section=new task_class(); |
- section.deadline=new timespec(); |
- section.wcet=new timespec(); |
- section.name="task"+task_group; |
- section.contract=task_server; |
- section.group=task_group; |
- section.act_number=act; |
- section.task_type=task_type; |
- section.localscheduler=localscheduler; |
- section.number=Integer.valueOf(e.getChild("number").getText()).intValue(); |
- |
- Element dl = e.getChild("dline"); |
- if (dl != null) { |
- |
- String[] dline=pattern.split(dl.getText()); |
- time.tv_sec = Long.valueOf(dline[0]).longValue(); |
- time.tv_nsec = Long.valueOf(dline[1]).longValue() * 1000; |
- |
- section.deadline.tv_sec=time.tv_sec; |
- section.deadline.tv_nsec=time.tv_nsec; |
- |
- } |
- |
- |
- Element wc = e.getChild("wcet"); |
- if (wc != null) { |
- |
- String[] wcet=pattern.split(e.getChild("wcet").getText()); |
- time.tv_sec = Long.valueOf(wcet[0]).longValue(); |
- time.tv_nsec = Long.valueOf(wcet[1]).longValue() * 1000; |
- |
- section.wcet.tv_sec=time.tv_sec; |
- section.wcet.tv_nsec=time.tv_nsec; |
- |
- } |
- |
- Task_Section.add(section); |
- task_group++; |
- |
-} |
- |
-void process_back_task(Element e, OutputStreamWriter out) { |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- Element exec_section=e.getChild("exec_section"); |
- |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n"); |
- out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n"); |
- |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- |
- } |
-} |
-void process_oneshot_task(Element e, OutputStreamWriter out) { |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- |
- Element exec_section=e.getChild("exec_section"); |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n"); |
- out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n"); |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- } |
-} |
- |
-int process_cyclical_task(Element e, OutputStreamWriter out) { |
- |
- int activated=1; |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- Element act_section=e.getChild("act_section"); |
- String[] start_time=pattern.split(act_section.getChild("start_time").getText()); |
- String[] period=pattern.split(act_section.getChild("period_time").getText()); |
- Element deltatime=act_section.getChild("delta_time"); |
- String[] delta_time; |
- |
- long act_delta=0; |
- timespec delta_act_ts = new timespec(); |
- |
- if (deltatime != null) { |
- delta_time = pattern.split(deltatime.getText()); |
- delta_act_ts.tv_sec = Long.valueOf(delta_time[0]).longValue(); |
- delta_act_ts.tv_nsec = Long.valueOf(delta_time[1]).longValue() * 1000; |
- act_delta = delta_act_ts.TIMESPEC2USEC(); |
- } |
- |
- Element exec_section=e.getChild("exec_section"); |
- String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText()); |
- Element execdelta=exec_section.getChild("delta_time"); |
- String[] exec_delta; |
- |
- long exec_delta_long = 0; |
- timespec exec_delta_ts = new timespec(); |
- |
- if (execdelta != null) { |
- exec_delta=pattern.split(execdelta.getText()); |
- exec_delta_ts.tv_sec = Long.valueOf(exec_delta[0]).longValue(); |
- exec_delta_ts.tv_nsec = Long.valueOf(exec_delta[1]).longValue() * 1000; |
- exec_delta_long = exec_delta_ts.TIMESPEC2USEC(); |
- } |
- |
- try { |
- out.write("struct timespec act_task"+task_group+"[]={{"+ |
- start_time[0]+","+start_time[1]+"},\n"); |
- |
- timespec time = new timespec(); |
- time.tv_sec = Long.valueOf(period[0]).longValue(); |
- time.tv_nsec = Long.valueOf(period[1]).longValue() * 1000; |
- |
- long usecperiod = time.TIMESPEC2USEC(); |
- timespec nextact = new timespec(); |
- |
- time.tv_sec = Long.valueOf(start_time[0]).longValue(); |
- time.tv_nsec = Long.valueOf(start_time[1]).longValue() * 1000; |
- |
- Random rd = new Random(); |
- |
- while (simulation_time.TIMESPEC_A_GT_B(time)) { |
- |
- nextact.tv_sec = Long.valueOf(period[0]).longValue(); |
- nextact.tv_nsec = Long.valueOf(period[1]).longValue() * 1000; |
- |
- if (act_delta != 0) { |
- nextact.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % act_delta - act_delta/2); |
- } |
- |
- time.ADDUSEC2TIMESPEC(usecperiod); |
- out.write(" {"+nextact.tv_sec+","+nextact.tv_nsec/1000+"},\n"); |
- activated++; |
- } |
- out.write("};\n"); |
- |
- out.write("struct timespec exec_task"+task_group+"[]={\n"); |
- |
- timespec nextexec = new timespec(); |
- |
- for (int i=0; i<activated; i++) { |
- |
- nextexec.tv_sec = Long.valueOf(exec_const[0]).longValue(); |
- nextexec.tv_nsec = Long.valueOf(exec_const[1]).longValue() * 1000; |
- |
- if (exec_delta_long != 0) { |
- nextexec.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % exec_delta_long - exec_delta_long/2); |
- } |
- |
- out.write(" {"+nextexec.tv_sec+","+nextexec.tv_nsec/1000+"},\n"); |
- |
- } |
- out.write("};\n"); |
- } |
- catch (java.io.IOException ex) { |
- System.out.println("File Exception: " + ex.getMessage()); |
- } |
- |
- return activated; |
-} |
- |
-void process_server_section(Element e, OutputStreamWriter out) { |
- |
- |
- List serverpars = e.getChildren(); |
- Iterator iterator = serverpars.iterator(); |
- Element serverpar = (Element) iterator.next(); |
- String current_value; |
- current_value=serverpar.getText(); |
- try { |
- out.write("{" + servernumber + ",{"); |
- servernumber++; |
- |
- Pattern pattern = Pattern.compile("[us\\s]+"); |
- /* cmin */ |
- String[] cmin = pattern.split(current_value); |
- out.write(cmin[0] + "," + Long.valueOf(cmin[1]).longValue()*1000+"},{"); |
- |
- /* tmax */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] tmax = pattern.split(current_value); |
- out.write(tmax[0] + "," + Long.valueOf(tmax[1]).longValue()*1000+"},{"); |
- |
- /* cmax */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] cmax = pattern.split(current_value); |
- out.write(cmax[0] + "," + Long.valueOf(cmax[1]).longValue()*1000+"},{"); |
- |
- /* tmin */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- String[] tmin = pattern.split(current_value); |
- out.write(tmin[0] + "," + Long.valueOf(tmin[1]).longValue()*1000+"},"); |
- |
- /*work load */ |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getText(); |
- out.write(current_value+","); |
- |
- serverpar = (Element) iterator.next(); |
- current_value=serverpar.getName(); |
- Attribute loc_type=serverpar.getAttribute("type"); |
- String scheduler=loc_type.getValue(); |
- if (scheduler.equals("POSIX")) { |
- out.write("30"); |
- } |
- else if (scheduler.equals("EDF")) { |
- out.write("31"); |
- } |
- else if (scheduler.equals("RM")) { |
- out.write("32"); |
- } |
- out.write(",-1},\n"); |
- local_scheduler.add(servernumber-1,serverpar); |
- |
- } catch (java.io.IOException ex) { |
- System.out.println ("File Exception: "+ex.getMessage()); |
- } |
- |
- /* |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload,(int)c->local_scheduler); |
- |
-*/ |
- //processElement (kid); |
- } |
- |
- |
- |
-public static void main(String[] args) throws Exception { |
- System.out.println("Parser Versione 1.0"); |
- Application app = new Application(); |
- if (args.length > 0) |
- app.process(args[0]); |
-} |
- |
-/* Event Generator |
- * |
- * Giacomo Guidi |
- */ |
- |
- |
- |
- |
- |
-/* |
-int write_basic_par_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
- |
-int write_basic_par(struct loader_task *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,act_%s,exec_%s},\n", |
- c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group, |
- (int)c->deadline.tv_sec, (int)c->deadline.tv_nsec, |
- (int)c->wcet.tv_sec, (int)c->wcet.tv_nsec, |
- (int)c->act_number, c->name, c->name); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract(struct loader_contract *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload,(int)c->local_scheduler); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_task(int total_task_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_contract(int total_contract_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_simulation_time(struct timespec *total) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
- |
-} |
- |
-int write_single_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- if (TIMESPEC_A_GT_B(t,&c->act_par_1)) { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- c->act_number = 1; |
- } else { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name); |
- c->act_number = 0; |
- } |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_periodic_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int period; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- period = TIMESPEC2USEC(&c->act_par_2); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- ADDUSEC2TIMESPEC(period,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- (int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_mean_act(struct timespec *t,struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int next_act; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2; |
- ADDUSEC2TIMESPEC(next_act,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- next_act / 1000000, next_act % 1000000 * 1000); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_const(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_exec_header," {%d,%d},\n", |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_mean(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int exec_time_usec; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- |
- for (i=0; i< c->act_number-1; i++) { |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header," {%d,%d},\n", |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- } |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-void *start; |
-void *end; |
- |
-int main(int argc, char **argv) { |
- |
- char loadfile[100]; |
- struct timespec total_time; |
- struct loader_task *start_loader_task = NULL, *current_t; |
- struct loader_contract *start_loader_contract = NULL, *current_c; |
- int err,ldnum; |
- int total_task_number; |
- int total_contract_number; |
- |
- printf("\nEvent Generator\n"); |
- |
- if (argc < 2) { |
- printf("Error: event_gen loadfile.fsf\n"); |
- exit(1); |
- } |
- |
- printf("Read loader file %s\n",argv[1]); |
- |
- sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]); |
- err = dos_preload(loadfile,100000,&start,&end); |
- |
- if (err != 0) { |
- printf("Error: File not found\n"); |
- exit(1); |
- } |
- |
- printf("Parsing file\n"); |
- |
- line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract); |
- |
- srandom(time(NULL)); |
- |
- write_struct(); |
- |
- current_t = start_loader_task; |
- ldnum = 1; |
- |
- while(current_t != NULL) { |
- |
- sprintf(current_t->name,"ltask%d",ldnum); |
- current_t->group = ldnum; |
- ldnum++; |
- |
- switch (current_t->act_type) { |
- case PAR_ACT_SINGLE: |
- err = write_single_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_PERIODIC: |
- err = write_periodic_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_MEAN: |
- err = write_mean_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->exec_type) { |
- case PAR_EXEC_CONST: |
- err = write_exec_const(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_EXEC_MEAN: |
- err = write_exec_mean(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- current_t = current_t->next; |
- |
- } |
- |
- write_basic_par_start(); |
- |
- total_task_number = 0; |
- current_t = start_loader_task; |
- while(current_t != NULL) { |
- |
- write_basic_par(current_t); |
- |
- current_t = current_t->next; |
- |
- total_task_number++; |
- |
- } |
- |
- close_loader_task(total_task_number); |
- |
- write_contract_start(); |
- |
- total_contract_number = 0; |
- current_c = start_loader_contract; |
- while(current_c != NULL) { |
- |
- write_contract(current_c); |
- |
- current_c = current_c->next; |
- |
- total_contract_number++; |
- |
- } |
- |
- close_loader_contract(total_contract_number); |
- |
- write_simulation_time(&total_time); |
- |
- return 0; |
- |
-} |
- |
-*/ |
-} |
Index: tags/rel_1_4_rc1/loader/generators/lread.c |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/lread.c (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/lread.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include "lparser.h" |
-#include "common/time.h" |
- |
-int dos_preload(char *file_name, long max_size, void **start_file, void **end_file) |
-{ |
- FILE *file; |
- void *buf; |
- long rd; |
- |
- |
- file = fopen(file_name,"r"); |
- if (file == NULL) return -1; |
- |
- buf = malloc(max_size); |
- *start_file = buf; |
- |
- while(((rd = fread(buf, 1, 2048, file)) == 2048) && |
- ((buf - *start_file + rd) < (max_size-2048))) { |
- buf += rd; |
- } |
- |
- *end_file = buf + rd; |
- |
- fclose(file); |
- return(0); |
- |
-} |
- |
-int line_reader(void *start_file, void *end_file, struct timespec *total, |
- struct loader_task **start_loader_task, struct loader_contract **start_loader_contract) |
-{ |
- |
- char *pbuf = start_file; |
- int res,line_num,total_loader_task,total_loader_contract; |
- struct loader_task *current_t = NULL; |
- struct loader_contract *current_c = NULL; |
- |
- NULL_TIMESPEC(total); |
- |
- line_num = 0; |
- total_loader_task = 0; |
- total_loader_contract = 0; |
- |
- while ((void *)(pbuf) < end_file) { |
- |
- line_num++; |
- |
- if (*start_loader_contract == NULL) |
- res = line_parser_contract(&pbuf, line_num, total, ¤t_c); |
- else |
- res = line_parser_contract(&pbuf, line_num, total, ¤t_c->next); |
- |
- if (res == 2) { |
- total_loader_contract++; |
- if (*start_loader_contract == NULL) |
- *start_loader_contract = current_c; |
- else |
- current_c = current_c->next; |
- } |
- |
- if (res == 3) break; |
- |
- } |
- |
- while ((void *)(pbuf) < end_file) { |
- |
- line_num++; |
- |
- if (*start_loader_task == NULL) |
- res = line_parser_task(&pbuf, line_num, ¤t_t); |
- else |
- res = line_parser_task(&pbuf, line_num, ¤t_t->next); |
- |
- if (res == 2) { |
- total_loader_task++; |
- if (*start_loader_task == NULL) |
- *start_loader_task = current_t; |
- else |
- current_t = current_t->next; |
- } |
- |
- if (res == 3) break; |
- |
- } |
- |
- printf("Total decoded lines %d\n",line_num); |
- printf("Total loader contract %d\n",total_loader_contract); |
- printf("Total loader task %d\n",total_loader_task); |
- printf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/loader/generators/lparser.c |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/lparser.c (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/lparser.c (nonexistent) |
@@ -1,479 +0,0 @@ |
-#include <stdlib.h> |
-#include <string.h> |
-#include <stdio.h> |
-#include "lparser.h" |
-#include "common/time.h" |
- |
-#define PARSER_DEBUG |
- |
-static int find_break(char **buf, int find_type, struct timespec *time, int *val) |
-{ |
- |
- int i; |
- char str[20]; |
- |
- i = 0; |
- while (((char *)(*buf))[i] == ' ' || ((char *)(*buf))[i] == ':' || |
- ((char *)(*buf))[i] == '\n' || ((char *)(*buf))[i] == '\r') i++; |
- *buf += i; |
- |
- if (!strncmp(*buf,"END",3) && find_type == PAR_NOTHING) { |
- *buf += 3; |
- return PAR_END; |
- } |
- |
- if (!strncmp(*buf,"CONTRACT SECTION",16) && find_type == PAR_NOTHING) { |
- *buf += 16; |
- return PAR_CONTRACT_SECTION; |
- } |
- |
- if (!strncmp(*buf,"TASK SECTION",12) && find_type == PAR_NOTHING) { |
- *buf += 12; |
- return PAR_TASK_SECTION; |
- } |
- |
- i = 0; |
- if (((char *)(*buf))[0] == '#' && find_type == PAR_NOTHING) { |
- while (((char *)(*buf))[i] != '\n' && ((char *)(*buf))[i] != '\r') i++; |
- *buf += i; |
- return PAR_FOUND; |
- } |
- |
- switch (find_type) { |
- |
- case PAR_NOTHING: |
- if (((char *)(*buf))[0] == ';' || |
- ((char *)(*buf))[0] < 32) { |
- *buf += 1; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TOTAL_EXEC_TIME: |
- if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) { |
- *buf += 16; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TIME: |
- if (((char *)(*buf))[0] != '[') return PAR_ERROR; |
- *buf += 1; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- time->tv_sec = atoi(str); |
- i += 2; |
- *buf += i; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- time->tv_nsec = atoi(str) * 1000; |
- i += 2; |
- *buf += i; |
- return PAR_FOUND; |
- break; |
- |
- case PAR_TASK_TYPE: |
- if (!strncmp(*buf, "OS:",3)) { |
- *val = PAR_TASK_OS; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf, "CT:",3)) { |
- *val = PAR_TASK_CT; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf, "BT:",3)) { |
- *val = PAR_TASK_BT; |
- *buf += 3; |
- return PAR_FOUND; |
- } |
- break; |
- |
- case PAR_TASK_NUMBER: |
- if (((char *)(*buf))[0] != '[') return PAR_ERROR; |
- *buf += 1; |
- i = 0; |
- while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') { |
- str[i] = ((char *)(*buf))[i]; |
- i++; |
- } |
- if (((char *)(*buf))[i] != ']') return PAR_ERROR; |
- str[i] = 0; |
- *val = atoi(str); |
- i += 2; |
- *buf += i; |
- return PAR_FOUND; |
- break; |
- |
- case PAR_ACT_TYPE: |
- if (!strncmp(*buf,"ACT_SINGLE(",11)) { |
- *buf += 11; |
- *val = PAR_ACT_SINGLE; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"ACT_PERIODIC(",13)) { |
- *buf += 13; |
- *val = PAR_ACT_PERIODIC; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"ACT_MEAN(",9)) { |
- *buf += 9; |
- *val = PAR_ACT_MEAN; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_LOCAL_SCHEDULER: |
- if (!strncmp(*buf,"POSIX",5)) { |
- *buf += 5; |
- *val = PAR_POSIX; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"EDF",3)) { |
- *buf += 3; |
- *val = PAR_EDF; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"RM",2)) { |
- *buf += 2; |
- *val = PAR_RM; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_EXEC_TYPE: |
- if (!strncmp(*buf,"EXEC_CONST(",11)) { |
- *buf += 11; |
- *val = PAR_EXEC_CONST; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"EXEC_MEAN(",10)) { |
- *buf += 10; |
- *val = PAR_EXEC_MEAN; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- case PAR_CRIT_SESSION: |
- if (!strncmp(*buf,"NO_CRIT",7)) { |
- *buf += 7; |
- *val = PAR_NO_CRIT; |
- return PAR_FOUND; |
- } |
- if (!strncmp(*buf,"CRIT(",5)) { |
- *buf += 5; |
- *val = PAR_CRIT; |
- return PAR_FOUND; |
- } |
- return PAR_ERROR; |
- break; |
- |
- } |
- |
- return PAR_ERROR; |
- |
-} |
- |
-void par_error(int line_num) |
-{ |
- |
- printf("\nParser error: line [%d]\n",line_num); |
- exit(1); |
- |
-} |
- |
-/* result: |
- * 0 -> nothing |
- * 1 -> total |
- * 2 -> new task-loader |
- * 3 -> end file |
- */ |
-int line_parser_task(char **pbuf, int line_num, struct loader_task **last) |
-{ |
- struct timespec time; |
- struct loader_task *ld = NULL; |
- int val, res; |
- |
- res = find_break(pbuf, PAR_NOTHING, &time, &val); |
- if (res == PAR_FOUND) return 0; |
- if (res == PAR_END) return 3; |
- |
- res = find_break(pbuf,PAR_TASK_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK TYPE = %d\n",val); |
- #endif |
- |
- ld = malloc(sizeof(struct loader_task)); |
- if (ld == NULL) par_error(line_num); |
- |
- ld->next = NULL; |
- *last = ld; |
- |
- ld->task_type = val; |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK SERVER = %d\n",val); |
- #endif |
- |
- ld->server = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK LOCAL SCHEDULER = %d\n",val); |
- #endif |
- |
- ld->local_scheduler = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("TASK NUMBER = %d\n",val); |
- #endif |
- |
- ld->number = val; |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("DEADLINE: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->deadline,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("WCET: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->wcet,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_ACT_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("ACTIVATION TYPE: %d (",val); |
- #endif |
- |
- ld->act_type = val; |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_1,&time); |
- } else par_error(line_num); |
- |
- if (ld->act_type != PAR_ACT_SINGLE) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_2,&time); |
- } else par_error(line_num); |
- } |
- |
- if (ld->act_type != PAR_ACT_SINGLE && ld->act_type != PAR_ACT_PERIODIC) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->act_par_3,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_EXEC_TYPE, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("EXEC TYPE: %d (",val); |
- #endif |
- ld->exec_type = val; |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->exec_par_1,&time); |
- } else par_error(line_num); |
- |
- if (ld->exec_type != PAR_EXEC_CONST) { |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->exec_par_2,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_CRIT_SESSION, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("CRITITCAL SESSION: %d (",val); |
- #endif |
- ld->crit_type = val; |
- if (ld->crit_type == PAR_CRIT) { |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("[%d]",val); |
- #endif |
- ld->resource = val; |
- } else par_error(line_num); |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&ld->crit_par,&time); |
- } else par_error(line_num); |
- } |
- |
- #ifdef PARSER_DEBUG |
- printf(")\n"); |
- #endif |
- |
- } else par_error(line_num); |
- |
- return 2; |
- |
-} |
- |
-int line_parser_contract(char **pbuf, int line_num, struct timespec *total, struct loader_contract **last) |
-{ |
- |
- struct timespec time; |
- struct loader_contract *lc = NULL; |
- int val, res; |
- |
- res = find_break(pbuf, PAR_NOTHING, &time, &val); |
- if (res == PAR_FOUND) return 0; |
- if (res == PAR_END) return 3; |
- |
- res = find_break(pbuf,PAR_TOTAL_EXEC_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- NULL_TIMESPEC(total); |
- res = find_break(pbuf, PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- TIMESPEC_ASSIGN(total,&time); |
- #ifdef PARSER_DEBUG |
- printf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec); |
- #endif |
- return 1; |
- } else par_error(line_num); |
- } |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("CONTRACT [%d]",val); |
- #endif |
- |
- lc = malloc(sizeof(struct loader_contract)); |
- if (lc == NULL) par_error(line_num); |
- |
- lc->next = NULL; |
- *last = lc; |
- |
- lc->number = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->cmin,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->tmax,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->cmax,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld],",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->tmin,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%d]\n",val); |
- #endif |
- |
- lc->workload = val; |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_TIME, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf(",[%ld][%ld],",time.tv_sec,time.tv_nsec/1000); |
- #endif |
- TIMESPEC_ASSIGN(&lc->deadline,&time); |
- } else par_error(line_num); |
- |
- res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val); |
- if (res == PAR_FOUND) { |
- #ifdef PARSER_DEBUG |
- printf("LOCAL SCHEDULER = %d\n",val); |
- #endif |
- |
- lc->local_scheduler = val; |
- } else par_error(line_num); |
- |
- return 2; |
- |
-} |
Index: tags/rel_1_4_rc1/loader/generators/event_gen.c |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/event_gen.c (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/event_gen.c (nonexistent) |
@@ -1,474 +0,0 @@ |
-/* Event Generator |
- * |
- * Giacomo Guidi |
- */ |
- |
-#include <stdio.h> |
-#include <stdlib.h> |
- |
-#include "lparser.h" |
-#include "lread.h" |
-#include "time.h" |
-#include "common/time.h" |
- |
-#define LOADFILE_DIR "../loadfile/" |
- |
-#define EVENT_DEFINE "event.c" |
-#define ACT_LIST "event.c" |
- |
-int write_struct(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"w"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "\n#include \"func.h\"\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_basic_par_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract_start(void) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, "struct loader_contract loader_contract_list[] = {\n"); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_basic_par(struct loader_task *c) |
-{ |
- |
- FILE *file_event_header; |
- int muxpres; |
- char muxtemp[30]; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- if (c->crit_type == PAR_CRIT) { |
- muxpres = 1; |
- sprintf(muxtemp,"block_%s",c->name); |
- } else { |
- muxpres = 0; |
- sprintf(muxtemp,"NULL"); |
- } |
- |
- fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,%d,%d,act_%s,exec_%s,%s},\n", |
- c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group, |
- (int)c->deadline.tv_sec, (int)c->deadline.tv_nsec, |
- (int)c->wcet.tv_sec, (int)c->wcet.tv_nsec, |
- (int)c->act_number, (int)c->resource, muxpres, c->name, c->name, muxtemp); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_contract(struct loader_contract *c) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,{%d,%d},%d,-1},\n", |
- (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec, |
- (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec, |
- (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec, |
- (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec, |
- (int)c->workload, |
- (int)c->deadline.tv_sec,(int)c->deadline.tv_nsec, |
- (int)c->local_scheduler); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_task(int total_task_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int close_loader_contract(int total_contract_number) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"};\n\n"); |
- |
- fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
-} |
- |
-int write_simulation_time(struct timespec *total) |
-{ |
- |
- FILE *file_event_header; |
- |
- file_event_header = fopen(EVENT_DEFINE,"a+"); |
- if (file_event_header == NULL) return 1; |
- |
- fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec); |
- |
- fclose(file_event_header); |
- |
- return 0; |
- |
- |
-} |
- |
-int write_single_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- if (TIMESPEC_A_GT_B(t,&c->act_par_1)) { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- c->act_number = 1; |
- } else { |
- fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name); |
- c->act_number = 0; |
- } |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_periodic_act(struct timespec *t, struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int period; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- period = TIMESPEC2USEC(&c->act_par_2); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- ADDUSEC2TIMESPEC(period,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- (int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_mean_act(struct timespec *t,struct loader_task *c) |
-{ |
- |
- FILE *file_act_header; |
- struct timespec tot_time; |
- int next_act; |
- |
- file_act_header = fopen(ACT_LIST,"a+"); |
- if (file_act_header == NULL) return 1; |
- |
- fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name, |
- (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec); |
- |
- c->act_number = 1; |
- TIMESPEC_ASSIGN(&tot_time,&c->act_par_1); |
- while (TIMESPEC_A_GT_B(t, &tot_time)) { |
- c->act_number++; |
- next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2; |
- ADDUSEC2TIMESPEC(next_act,&tot_time); |
- fprintf(file_act_header," {%d,%d},\n", |
- next_act / 1000000, next_act % 1000000 * 1000); |
- } |
- |
- fprintf(file_act_header," };\n\n"); |
- |
- fclose(file_act_header); |
- |
- return 0; |
- |
-} |
- |
-int write_block_const(struct loader_task *c) |
-{ |
- |
- FILE *file_block_header; |
- int i; |
- |
- file_block_header = fopen(ACT_LIST,"a+"); |
- if (file_block_header == NULL) return 1; |
- |
- fprintf(file_block_header,"struct timespec block_%s[] = {{%d,%d},\n",c->name, |
- (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_block_header," {%d,%d},\n", |
- (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec); |
- |
- fprintf(file_block_header," };\n\n"); |
- |
- fclose(file_block_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_const(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- for (i=0; i< c->act_number-1; i++) |
- fprintf(file_exec_header," {%d,%d},\n", |
- (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec); |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-int write_exec_mean(struct loader_task *c) |
-{ |
- |
- FILE *file_exec_header; |
- int exec_time_usec; |
- int i; |
- |
- file_exec_header = fopen(ACT_LIST,"a+"); |
- if (file_exec_header == NULL) return 1; |
- |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name, |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- |
- for (i=0; i< c->act_number-1; i++) { |
- exec_time_usec = TIMESPEC2USEC(&c->exec_par_1) |
- + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2; |
- fprintf(file_exec_header," {%d,%d},\n", |
- exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000); |
- } |
- |
- fprintf(file_exec_header," };\n\n"); |
- |
- fclose(file_exec_header); |
- |
- return 0; |
- |
-} |
- |
-void *start; |
-void *end; |
- |
-int main(int argc, char **argv) { |
- |
- char loadfile[100]; |
- struct timespec total_time; |
- struct loader_task *start_loader_task = NULL, *current_t; |
- struct loader_contract *start_loader_contract = NULL, *current_c; |
- int err,ldnum; |
- int total_task_number; |
- int total_contract_number; |
- |
- printf("\nEvent Generator\n"); |
- |
- if (argc < 2) { |
- printf("Error: event_gen loadfile.fsf\n"); |
- exit(1); |
- } |
- |
- printf("Read loader file %s\n",argv[1]); |
- |
- sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]); |
- err = dos_preload(loadfile,100000,&start,&end); |
- |
- if (err != 0) { |
- printf("Error: File not found\n"); |
- exit(1); |
- } |
- |
- printf("Parsing file\n"); |
- |
- line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract); |
- |
- srandom(time(NULL)); |
- |
- write_struct(); |
- |
- current_t = start_loader_task; |
- ldnum = 1; |
- |
- while(current_t != NULL) { |
- |
- sprintf(current_t->name,"ltask%d",ldnum); |
- current_t->group = ldnum; |
- ldnum++; |
- |
- switch (current_t->act_type) { |
- case PAR_ACT_SINGLE: |
- err = write_single_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_PERIODIC: |
- err = write_periodic_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_ACT_MEAN: |
- err = write_mean_act(&total_time,current_t); |
- if (err != 0) { |
- printf("Error writing activation header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->exec_type) { |
- case PAR_EXEC_CONST: |
- err = write_exec_const(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- case PAR_EXEC_MEAN: |
- err = write_exec_mean(current_t); |
- if (err != 0) { |
- printf("Error writing exec header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- switch (current_t->crit_type) { |
- case PAR_CRIT: |
- err = write_block_const(current_t); |
- if (err != 0) { |
- printf("Error writing block header\n"); |
- exit(1); |
- } |
- break; |
- } |
- |
- current_t = current_t->next; |
- |
- } |
- |
- write_basic_par_start(); |
- |
- total_task_number = 0; |
- current_t = start_loader_task; |
- while(current_t != NULL) { |
- |
- write_basic_par(current_t); |
- |
- current_t = current_t->next; |
- |
- total_task_number++; |
- |
- } |
- |
- close_loader_task(total_task_number); |
- |
- write_contract_start(); |
- |
- total_contract_number = 0; |
- current_c = start_loader_contract; |
- while(current_c != NULL) { |
- |
- write_contract(current_c); |
- |
- current_c = current_c->next; |
- |
- total_contract_number++; |
- |
- } |
- |
- close_loader_contract(total_contract_number); |
- |
- write_simulation_time(&total_time); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/loader/generators/lread.h |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/lread.h (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/lread.h (nonexistent) |
@@ -1,11 +0,0 @@ |
-#ifndef __LREAD_H__ |
-#define __LREAD_H__ |
- |
-#include "lparser.h" |
- |
-int dos_preload(char *file_name, long max_size, void **start, void **end); |
- |
-int line_reader(void *start, void *end, struct timespec *total, |
- struct loader_task **start_loader_task, struct loader_contract **start_loader_contract); |
- |
-#endif |
Index: tags/rel_1_4_rc1/loader/generators/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/makefile (nonexistent) |
@@ -1,9 +0,0 @@ |
-event_gen: |
- gcc -o lparser.o -c -Wall lparser.c -I. -I.. |
- gcc -o lread.o -c -Wall lread.c -I. -I.. |
- gcc -o event_gen -Wall lparser.o lread.o -I. -I.. -lc event_gen.c |
- |
-clean: |
- rm -f *.o |
- rm -f event_gen |
- |
Index: tags/rel_1_4_rc1/loader/generators/lparser.h |
=================================================================== |
--- tags/rel_1_4_rc1/loader/generators/lparser.h (revision 1476) |
+++ tags/rel_1_4_rc1/loader/generators/lparser.h (nonexistent) |
@@ -1,58 +0,0 @@ |
-#ifndef __LPARSER_H__ |
-#define __LPARSER_H__ |
- |
-#include "common/lconst.h" |
- |
-struct loader_task { |
- |
- char name[20]; |
- int number; |
- int group; |
- int server; |
- int local_scheduler; |
- int task_type; |
- |
- int act_type; |
- struct timespec act_par_1; |
- struct timespec act_par_2; |
- struct timespec act_par_3; |
- int exec_type; |
- struct timespec exec_par_1; |
- struct timespec exec_par_2; |
- |
- struct timespec deadline; |
- struct timespec wcet; |
- |
- int act_number; |
- struct timespec *act; |
- struct timespec *exec; |
- |
- int crit_type; |
- int resource; |
- struct timespec crit_par; |
- |
- struct loader_task *next; |
- |
-}; |
- |
-struct loader_contract { |
- |
- int number; |
- struct timespec cmin; |
- struct timespec tmax; |
- struct timespec cmax; |
- struct timespec tmin; |
- int workload; |
- struct timespec deadline; |
- int local_scheduler; |
- |
- struct loader_contract *next; |
- |
-}; |
- |
-int line_parser_contract(char **buf, int line_num, struct timespec *total_time, struct loader_contract **last); |
- |
-int line_parser_task(char **buf, int line_num, struct loader_task **last); |
- |
-#endif |
- |
Index: tags/rel_1_4_rc1/loader/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/loader/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/loader/readme.txt (nonexistent) |
@@ -1,64 +0,0 @@ |
-FIRST Framework Evaluation architecture |
---------------------------------------- |
- |
-makefile usage: |
- |
-$ make OS=<osname> TEST=<demo> all |
- |
-where: |
- |
-<osname> is the name of the target operating system and it can be: |
- |
-- MARTE for MaRTE OS |
-- SHARK for Shark |
- |
-<demo> is the name of the test case that have to be compiled. The |
-specification of the test case is contained inside the loadfile |
-directory. |
- |
-Valid extensions for the test case specification files are: |
-.fsf - old script file |
-.fsf2 - XML version |
-(other extensions can be added easily) |
- |
-For example: |
- |
-make OS=SHARK TEST=load all |
- |
-these makefile will: |
-- prepare the out directory with the common files |
-- add the shark initialization files |
-- parse a file loadfile/load.fsf (the file extension is guessed automatically |
- by the makefile) to produce source code inside out |
-- compile the resulting shark application |
- |
-------------------------------------------------------------------------- |
- |
-XML Parser & Java setup |
- |
-To use the XML parser (file extension .fsf2) you need to properly setup |
-your system, and you need toinstall the following libraries: |
- |
-- JDOM BETA 9 - http://www.jdom.org |
-- XERCES (Parser SAX with XSD support) - http://xml.apache.org |
- |
-On my Linux system, after installing the Sun's j2re, |
-I did the following commands (as root): |
- |
-# mkdir j |
-# cd j |
-# wget http://www.jdom.org/dist/binary/jdom-b9.tar.gz |
-# tar xvzf jdom-b9.tar.gz |
-# cp jdom-b9/build/jdom.jar /usr/java/j2re1.4.1_02/lib/ |
-# wget http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.6.0.tar.gz |
-# tar xvzf Xerces-J-bin.2.6.0.tar.gz |
-# cp ./xerces-2_6_0/xercesImpl.jar /usr/java/j2re1.4.1_02/lib/ |
-# cp ./xerces-2_6_0/xml-apis.jar /usr/java/j2re1.4.1_02/lib/ |
- |
-then, as user, I did |
- |
-$ export CLASSPATH=/usr/java/j2re1.4.1_02/lib |
- |
-Enjoy, |
- |
-Michael, Giacomo, PJ |
Index: tags/rel_1_4_rc1/loader/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/loader/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/loader/makefile (nonexistent) |
@@ -1,88 +0,0 @@ |
-# |
-# help can be found in readme.txt |
-# |
- |
-# ----------------------------------------------------- |
-# |
-# OS dependent variables: |
- |
-# all the OS dependent variables and dependencies are under $(OS)/makefile.in |
- |
-# This makefile will execute the dependency os_specific_dep to "fill" |
-# the out directory with OS-specific stuffs; Then, the makefile |
-# generated in the out directory will be executed with $(TEST) as |
-# parameter. |
- |
-ifndef $(BASE) |
-BASE=../.. |
-endif |
- |
-include $(BASE)/config/config.mk |
- |
-ifeq ($(OS),MARTE) |
-OSINCLUDE=marte/makefile.in |
-endif |
- |
-ifeq ($(OS),SHARK) |
-OSINCLUDE=shark/makefile.in |
-endif |
- |
-# ----------------------------------------------------- |
- |
-.PHONY: all clean help |
- |
-help: |
-ifeq ($(CAT),cat) |
- cat readme.txt |
-endif |
- |
-all: out out/common.done out/$(TEST).done os_specific_dep |
- make -C out $(TEST) |
- |
-clean: |
- make -C generators clean |
- make -C generators/java clean |
- rm -rf out |
- |
-out/common.done: |
- cd out; cp -sf ../common/*.c . |
- cd out; cp -sf ../common/*.h . |
- touch out/common.done |
- |
-# note: the out dependency is present only in the "all" dependency |
-# (there is some strange case with the updating of the out date that I |
-# do not know how to resolve... |
-out: |
- mkdir out |
- |
-# ----------------------------------------------------- |
-# |
-# Testcase generation |
- |
-# .FSF Format |
-# ----------------------- |
- |
-generators/event_gen: |
- make -C generators event_gen |
- |
-out/%.done: loadfile/%.fsf generators/event_gen |
- cd out; ../generators/event_gen ../loadfile/$(TEST).fsf |
- touch out/$*.done |
- |
-# .FSF2 Format |
-# ----------------------- |
- |
-generators/java/Applicazione.class: |
- make -C generators/java all |
- |
-out/%.done: loadfile/%.fsf2 generators/java/Applicazione.class |
- cd generators/java; ./java_gen ../../loadfile/$(TEST).fsf2; mv event.c ../../out/ |
- touch out/$*.done |
- |
-# other file formats |
-# ----------------------- |
-out/%.done: loadfile/%.otherformat |
- echo Other file formats that are not specified yet... |
- touch out/$*.done |
- |
-include $(OSINCLUDE) |
Index: tags/rel_1_4_rc1/jumpball/rrn.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/rrn.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/rrn.c (nonexistent) |
@@ -1,219 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rrn.c,v 1.5 2004-04-19 13:45:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2004-04-19 13:45:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/nop.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- RR_register_level(RRTICK, RR_MAIN_NO, mb); // this module remains empty!!! |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- NOP_mutexattr_t attr; |
- |
- NOP_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
- |
Index: tags/rel_1_4_rc1/jumpball/rrp.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/rrp.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/rrp.c (nonexistent) |
@@ -1,219 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: rrp.c,v 1.5 2004-04-19 13:45:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2004-04-19 13:45:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/pi.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- PI_mutexattr_t attr; |
- |
- PI_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
- |
Index: tags/rel_1_4_rc1/jumpball/demo.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/demo.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/demo.c (nonexistent) |
@@ -1,198 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: demo.c,v 1.7 2004-04-18 18:48:22 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.7 $ |
- Last update: $Date: 2004-04-18 18:48:22 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000-2003 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "demo.h" |
-#include <kernel/func.h> |
-#include <string.h> |
-#include <stdlib.h> |
- |
-/* useful colors... */ |
-int white; |
-int black; |
-int red; |
-int gray; |
- |
-void app_mutex_init(mutex_t *m); |
- |
-static void version( void ) |
-{ |
- cprintf( "S.Ha.R.K. Jumpball Demo 1.0\n" ); |
- cprintf( "---------------------------\n" ); |
- cprintf( "by Paolo Gai 1999-2001\n" ); |
- cprintf( " <pj@sssup.it>\n" ); |
- cprintf( "---------------------------\n" ); |
-} |
- |
-int myrand(int x) |
-{ |
- return rand()%x; |
-} |
- |
-void reverse(char s[]) |
-{ |
- int c, i, j; |
- |
- for (i = 0, j = strlen(s)-1; i<j; i++, j--) |
- { |
- c = s[i]; |
- s[i] = s[j]; |
- s[j] = c; |
- } |
-} |
- |
-char * itoa(int n, char *s) |
-{ |
- int i, sign; |
- |
- if ((sign = n) < 0) |
- n = -n; |
- |
- i = 0; |
- |
- do |
- { |
- s[i++] = n % 10 + '0'; |
- } while ((n /= 10) > 0); |
- |
- if (sign < 0) |
- s[i++] = '-'; |
- |
- s[i] = 0; |
- |
- reverse(s); |
- |
- return s; |
-} |
- |
- |
-void scenario() |
-{ |
- grx_text("S.Ha.R.K. Jumpball Demo 1.0", 0, 0, rgb16(0,255,0), black ); |
- grx_text(" by Paolo Gai 1999-2001" , 0, 8, rgb16(0,255,0), black ); |
- grx_text(" pj@sssup.it" , 0,16, rgb16(0,255,0), black ); |
- |
- grx_text("Ctrl-C, Ctrr-C, Enter: exit" ,320, 0, gray, black ); |
- grx_text("Alt-C : void statistics" ,320, 8, gray, black ); |
- grx_text("Space : create noise ball",320,16, gray, black ); |
- grx_text("Backspace : kill noise balls" ,320,24, gray, black ); |
- |
- |
- #ifdef JET_ON |
- scenario_jetcontrol(); |
- #endif |
- |
- #ifdef BALL_ON |
- scenario_ball(); |
- #endif |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-void zerofun(KEY_EVT *k) |
-{ |
- int i; |
- for (i=0; i<MAX_PROC; i++) jet_delstat(i); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- KEY_EVT k; |
- |
- version(); |
- |
- srand(4); |
- |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,endfun,FALSE); |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,endfun,FALSE); |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,zerofun,FALSE); |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,endfun,FALSE); |
- |
- /* init the graphic mutex */ |
- app_mutex_init(&mutex); |
- |
- /* useful colors ... */ |
- white = rgb16(255,255,255); |
- black = rgb16(0,0,0); |
- red = rgb16(255,0,0); |
- gray = rgb16(128,128,128); |
- |
- scenario(); |
- |
- #ifdef JET_ON |
- init_jetcontrol(); |
- #endif |
- |
- #ifdef BALL_ON |
- init_ball(); |
- #endif |
- |
- group_activate(1); |
- |
- return 0; |
-} |
- |
- |
Index: tags/rel_1_4_rc1/jumpball/ern.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/ern.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/ern.c (nonexistent) |
@@ -1,220 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ern.c,v 1.5 2004-04-19 13:45:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2004-04-19 13:45:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/nop.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- NOP_mutexattr_t attr; |
- |
- NOP_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
- |
Index: tags/rel_1_4_rc1/jumpball/ecp.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/ecp.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/ecp.c (nonexistent) |
@@ -1,216 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ecp.c,v 1.5 2004-04-19 13:45:15 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.5 $ |
- Last update: $Date: 2004-04-19 13:45:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2003 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/pi.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- PI_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
-void app_mutex_init(mutex_t *m) |
-{ |
- PI_mutexattr_t attr; |
- |
- PI_mutexattr_default(attr); |
- |
- mutex_init(m, &attr); |
-} |
Index: tags/rel_1_4_rc1/jumpball/jetctrl.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/jetctrl.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/jetctrl.c (nonexistent) |
@@ -1,236 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: jetctrl.c,v 1.4 2004-04-18 18:48:22 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2004-04-18 18:48:22 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-// JetControl |
- |
-#include "demo.h" |
-#include "kernel/func.h" |
- |
-TASK jetdummy_task(void *arg) |
-{ |
- TIME now_dummy, last_dummy, diff_dummy, slice; |
- struct timespec now, last, diff; |
- int x = 0; |
- int height; |
- |
- NULL_TIMESPEC(&last); |
- last_dummy = 0; |
- for (;;) { |
- task_nopreempt(); |
- jet_getstat(DUMMY_PID, NULL, NULL, NULL, &now_dummy); |
- sys_gettime(&now); |
- task_preempt(); |
- |
- SUBTIMESPEC(&now, &last, &diff); |
- slice = diff.tv_sec * 1000000 + diff.tv_nsec/1000; |
- diff_dummy = now_dummy - last_dummy; |
- |
- height = (int)(JET_DUMMY_HEIGHT*((float)diff_dummy)/((float)slice)); |
- |
- TIMESPEC_ASSIGN(&last, &now); |
- last_dummy = now_dummy; |
- |
- grx_line(JET_DUMMY_X+x,JET_DUMMY_Y, |
- JET_DUMMY_X+x,JET_DUMMY_Y+height ,black); |
- grx_line(JET_DUMMY_X+x,JET_DUMMY_Y+height, |
- JET_DUMMY_X+x,JET_DUMMY_Y+JET_DUMMY_HEIGHT,white); |
- grx_line(JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y, |
- JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y+JET_DUMMY_HEIGHT,255); |
- |
- x = (x+1)%JET_DUMMY_WIDTH; |
- |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK jetctrl_task(void *arg) |
-{ |
- char st[50]; |
- TIME sum, max; |
- int n; |
- |
- PID i; |
- int printed = 0; |
- |
- for (;;) { |
- for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
- if (jet_getstat(i, &sum, &max, &n, NULL) != -1) { |
- if (!n) n=1; |
- sprintf(st, "%6d %6d %10s", (int)sum/n, (int)max, proc_table[i].name); |
- grx_text(st, 384, JET_Y_NAME+16+printed*8, gray, black); |
- printed++; |
- } |
- } |
- while (printed<JET_NTASK) { |
- grx_text(" ", |
- 384, JET_Y_NAME+16+printed*8, gray, black); |
- printed++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK jetslide_task(void *arg) |
-{ |
- TIME sum, curr, max; |
- |
- TIME total[JET_NTASK]; |
- int slides[JET_NTASK]; |
- |
- PID i; |
- int printed = 0; |
- |
- for (;;) { |
- // Fill the total array in a nonpreemptive section |
- task_nopreempt(); |
- for (i=2, printed=0; i<MAX_PROC && printed<JET_NTASK; i++) { |
- if (jet_getstat(i, &sum, NULL, NULL, &curr) != -1) { |
- total[printed] = sum+curr; |
- printed++; |
- } |
- } |
- task_preempt(); |
- |
- while (printed < JET_NTASK) |
- total[printed++] = 0; |
- |
- // Compute the Max elapsed time |
- max = 0; |
- for (i=0; i<JET_NTASK; i++) |
- if (total[i] > max) max = total[i]; |
- if (!max) max = 1; |
- |
- // Compute the slides width |
- for (i=0; i<JET_NTASK; i++) |
- slides[i] = (int)( (((float)total[i])/max) * JET_SLIDE_WIDTH); |
- |
- // print the data |
- for (i=0; i<JET_NTASK; i++) { |
- grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+slides[i], JET_Y_NAME+23+i*8, gray); |
- grx_box(JET_SLIDE_X+slides[i], JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+23+i*8, black); |
- } |
- |
- while (i<JET_NTASK) { |
- grx_box(JET_SLIDE_X, JET_Y_NAME+16+i*8, |
- JET_SLIDE_X+JET_SLIDE_WIDTH, JET_Y_NAME+20+i*8, black); |
- i++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
- |
-void scenario_jetcontrol(void) |
-{ |
- grx_text("System load" , 384, 45, rgb16(0,0,255), black); |
- grx_line(384,55,639,55,red); |
- |
- grx_text(" Mean Max Name Slide", 384, JET_Y_NAME, gray, black); |
- grx_line(384,JET_Y_NAME+10,639,JET_Y_NAME+10,gray); |
- |
- grx_rect(JET_DUMMY_X-1, JET_DUMMY_Y-1, |
- JET_DUMMY_X+JET_DUMMY_WIDTH, JET_DUMMY_Y+JET_DUMMY_HEIGHT+1, gray); |
- |
- grx_text("100%", JET_DUMMY_X-40, JET_DUMMY_Y, gray, black); |
- grx_text(" 0%", JET_DUMMY_X-40, JET_DUMMY_Y+JET_DUMMY_HEIGHT-8, gray, black); |
- |
- grx_line(JET_DUMMY_X-1, JET_DUMMY_Y, JET_DUMMY_X-5, JET_DUMMY_Y, gray); |
- grx_line(JET_DUMMY_X-1, JET_DUMMY_Y+JET_DUMMY_HEIGHT, JET_DUMMY_X-5, JET_DUMMY_Y+JET_DUMMY_HEIGHT, gray); |
-} |
- |
-void init_jetcontrol(void) |
-{ |
- SOFT_TASK_MODEL m3, m4, m5; |
- |
- PID p3, p4, p5; |
- |
- soft_task_default_model(m3); |
- soft_task_def_level(m3,2); |
- soft_task_def_period(m3, PERIOD_JETCTRL); |
- soft_task_def_met(m3, WCET_JETCTRL); |
- soft_task_def_ctrl_jet(m3); |
- soft_task_def_group(m3, 1); |
- p3 = task_create("jctrl", jetctrl_task, &m3, NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("Could not create task <jetctrl> errno=%d", |
- errno); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m4); |
- soft_task_def_level(m4,2); |
- soft_task_def_period(m4, PERIOD_JETDUMMY); |
- soft_task_def_met(m4, WCET_JETDUMMY); |
- soft_task_def_group(m4, 1); |
- soft_task_def_usemath(m4); |
- soft_task_def_ctrl_jet(m4); |
- p4 = task_create("jdmy", jetdummy_task, &m4, NULL); |
- if (p4 == -1) { |
- sys_shutdown_message("Could not create task <jetdummy> errno=%d", |
- errno); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m5); |
- soft_task_def_level(m5,2); |
- soft_task_def_period(m5, PERIOD_JETSLIDE); |
- soft_task_def_met(m5, WCET_JETSLIDE); |
- soft_task_def_group(m5, 1); |
- soft_task_def_usemath(m5); |
- soft_task_def_ctrl_jet(m5); |
- p5 = task_create("jsli", jetslide_task, &m5, NULL); |
- if (p5 == -1) { |
- sys_shutdown_message("Could not create task <jetslide> errno=%d", |
- errno); |
- sys_end(); |
- } |
-} |
- |
Index: tags/rel_1_4_rc1/jumpball/demo.h |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/demo.h (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/demo.h (nonexistent) |
@@ -1,183 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: demo.h,v 1.6 2004-04-18 09:45:27 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.6 $ |
- Last update: $Date: 2004-04-18 09:45:27 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
-#include <ll/ll.h> |
-#include <kernel/types.h> |
-#include <kernel/descr.h> |
-#include <math.h> |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/* Subparts */ |
-#define JET_ON |
-#define BALL_ON |
- |
- |
-/* CPU Speed Selection |
- -------------------------------------------------------------------- |
- 1700 - Pentium 4 1.7 GHz |
- 1300 - Centrino 1.3 GHz |
- 400 - Pentium 2 400 MHz |
- 133 - Pentium 1 133 MHz |
-*/ |
-#define CPU 400 |
- |
-/* |
- * |
- * WCET, Periods and Models |
- * |
- */ |
- |
-#if CPU==133 |
-#define WCET_JETCTRL 10000 |
-#define WCET_JETDUMMY 300 |
-#define WCET_JETSLIDE 2000 |
-#define WCET_BALL 250 |
-#define WCET_HARD_BALL 1000 |
-#define BALL_DELAY 10000 |
-#endif |
- |
-#if CPU==400 |
-#define WCET_JETCTRL 7500 |
-#define WCET_JETDUMMY 200 |
-#define WCET_JETSLIDE 2100 |
-#define WCET_BALL 100 |
-#define WCET_HARD_BALL 380 |
-#define BALL_DELAY 10000 |
-#endif |
- |
-#if CPU==1300 |
-#define WCET_JETCTRL 4500 |
-#define WCET_JETDUMMY 100 |
-#define WCET_JETSLIDE 1300 |
-#define WCET_BALL 100 |
-#define WCET_HARD_BALL 650 |
-#define BALL_DELAY 100000 |
-#endif |
- |
-#if CPU==1700 |
-#define WCET_JETCTRL 4500 |
-#define WCET_JETDUMMY 100 |
-#define WCET_JETSLIDE 1300 |
-#define WCET_BALL 100 |
-#define WCET_HARD_BALL 410 |
-#define BALL_DELAY 100000 |
-#endif |
- |
-#define PERIOD_JETCTRL 100000 |
-#define PERIOD_JETDUMMY 100000 |
-#define PERIOD_JETSLIDE 100000 |
-#define PERIOD_BALL 10000 |
- |
-/* |
- * |
- * Global Stuffs |
- * |
- */ |
- |
-extern PID shutdown_task_PID; |
- |
-/* graphic mutex... */ |
-extern mutex_t mutex; |
- |
-/* useful colors... */ |
-extern int white; |
-extern int black; |
-extern int red; |
-extern int gray; |
- |
-void init_jetcontrol(); |
-void init_ball(void); |
-void scenario_jetcontrol(); |
-void scenario_ball(); |
-char *itoa(int n, char *s); |
-int myrand(int x); |
- |
-/* |
- * |
- * JETCONTROL stuffs |
- * |
- */ |
- |
-#define JET_NTASK 35 |
-#define JET_Y_NAME 170 |
- |
-#define DUMMY_PID 1 |
- |
-#define JET_DUMMY_WIDTH 210 |
-#define JET_DUMMY_HEIGHT 80 |
- |
-/* the point (x, y) is the top left corner */ |
-#define JET_DUMMY_X 428 |
-#define JET_DUMMY_Y 65 |
- |
-#define JET_SLIDE_WIDTH 50 |
-#define JET_SLIDE_X 576 |
- |
-/* |
- * |
- * BALL stuffs |
- * |
- */ |
- |
-// x and y corners are specified whithout consider a border of 3 pixels |
-#define BALL_Y 450 /* position of the floor */ |
-#define BALL_HEIGHT 385 /* initial height of the ball */ |
-#define BALL_XMIN 10 /* min position X of the ball */ |
-#define BALL_XMAX 370 /* max position X of the ball */ |
-#define BALL_VELX 5. /* horizontal ball velocity */ |
-#define BALL_VYMIN 11. /* min ground speed */ |
-#define BALL_MAX_P 60 /* max number of balls */ |
- |
-#define BALL_GROUP 2 /* task group of the balls */ |
Index: tags/rel_1_4_rc1/jumpball/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/readme.txt (nonexistent) |
@@ -1,94 +0,0 @@ |
----------------------------------- |
-Jumping Balls demo |
- |
-by |
- |
-Paolo Gai 1999-2001 - pj@sssup.it |
- |
----------------------------------- |
- |
-This demo was created to show some S.Ha.R.K. functionalities in the course |
-of Informatica Industriale , University of Pavia, Italy. |
- |
-The demo is composed by an application (derived by the template application |
-distributed on the web site) and two init files. |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application; |
- demo is the rule to compile the application with a CBS scheduler |
- demo2 is the rule to compile the application with a RR scheduler |
-README.TXT This file |
-DEMO.H Some constants used into the demo |
-ECP.C, ERN.C, RRP.C, RRN.C Various initfiles |
-INITFIL2.C The EDF initfile |
-INITFILE.C A makefile that cover either EDF+CBS and RR |
-BALL.C The Jumping balls part of the demo |
-DEMO.C The main() function and some other utility function |
-JETCTRL.C The JET part of the demo |
- |
-The demo works as follows: |
-- It works at 640x480 16 bit colors |
-- on the left, there is the jumping ball arena, on the rigth there is the |
- statistics about the tasks into the system. |
- |
-- the tasks are guaranteed using CBS and EDF. The wcet and mean execution |
- time on my portable after a few minutes are (us): |
- |
- JetCtrl 7400 max 7500 CBS met |
- JetDummy 135 max 200 CBS met |
- JetSlide 2100 max 2100 CBS met |
- Balls 276 max 380 EDF wcet for hard ball,100 CBS met for soft ones |
- |
- The system should go overloaded with 40 soft balls. |
- |
-- The idea is the following: |
- - first, an edf guaranteed ball is created. |
- - then, create a set of soft ball using space. since their met is < than the |
- real met, they posticipate the deadlines. |
- - if they are killed, they remain for some seconds in the zombie state |
- - if a set of soft ball arde created (i.e., 10), and after a while all the |
- others are created, the bandwidth is fully used, and the task posticipate |
- their deadlines. the first set of tasks stops jumping when the bandwidth |
- is full utilized by the newest balls until all the tasks have similar |
- deadlines. |
- - Note on the left the slides that represents the relative ratio |
- between the tasks. |
- - Note that in overload conditions the EDF task is still guaranteed |
- - Note that PI is used with EDF, also if no theory says that it is good: |
- - S.Ha.R.K. allows that, it is the user that have to choose if that is |
- a non-sense |
- - PI is independent from the implemnentation of the scheduling modules |
- - if the second init file is used, RR is used instead of EDF+CBS. |
- - In overload condition RR perform differently from EDF+CBS, giving to |
- each task an equal fraction of bandwidth |
- |
- - note also: |
- - the redefinition of the standard exception handler |
- - the redefinition of the keys and the initialization of the keyboard |
- - the myend exit function |
- - the main() that terminates |
- - the two parts (ball and jet) can be excluded using a #define |
- |
-If You have any question, please contact the author... |
- |
-Update (2003/12/19): |
-Just some more notes... |
-I usually show the four demos in the following order: |
- |
-(first of all, tune the demo depending on how fast your notebook is; see demo.h) |
- |
-ECP - EDF with CBS and PI... the white EDF ball still work also in overload; CBS balls just slow down but they still get their guaranteed bandwidth |
- |
-RRP - Round Robin with Priority inheritance ... the EDF ball is at the same level of the others, all slow down... |
- |
-RRN - 2 levels of Round Robin, without Priority inheritance ... when |
-there is overload, the white ball works ok, but the other have an impredicible |
-behavior (they execute many instances in one RR period) |
- |
-ERN - EDF, RR, no priority inheritance - the white ball misses his deadline |
-just when there is an overload (all the other balls are queued on the same |
-semaphore, so the blocking time increase, and when there is overload the EDF |
-task misses also if it has not consumed his bandwidth). Note that it happens |
-also if the EDF task consume just a few microseconds... Real time does not |
-means "fast" :-) |
Index: tags/rel_1_4_rc1/jumpball/ball.c |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/ball.c (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/ball.c (nonexistent) |
@@ -1,247 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ball.c,v 1.6 2004-04-18 18:48:22 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.6 $ |
- Last update: $Date: 2004-04-18 18:48:22 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* SIMULATION OF JUMPING BALLS */ |
-/*--------------------------------------------------------------*/ |
- |
-#include "demo.h" |
-#include <kernel/func.h> |
-#include <stdlib.h> |
- |
-#define R 8 /* dimension of a ball */ |
-#define G 9.8 /* acceleration of gravity */ |
- |
-static int ballexit = 0; |
-static int npc = 0; /* number of tasks created */ |
- |
-/*--------------------------------------------------------------*/ |
-/* Delay function for jumping balls */ |
-/*--------------------------------------------------------------*/ |
- |
-void my_delay(void) |
-{ |
- int xxx; |
- for (xxx=0; xxx<BALL_DELAY; xxx++); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* Periodic task for ball simulation */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK palla(int i) |
-{ |
-int x, y; /* coordinate grafiche pallina */ |
-int ox, oy; /* vecchia posizione pallina */ |
-int x0, y0; /* posizione iniziale X pallina */ |
-float vx, vy; /* velocit
della pallina */ |
-float vy0; /* velocita' pallina al primo rimbalzo */ |
-float ty, tx; /* variabile temporale */ |
-float dt; /* incremento temporale */ |
- |
- y = oy = y0 = BALL_HEIGHT; |
- x = ox = x0 = BALL_XMIN; |
- |
- vy0= sqrt(2. * G * (float)BALL_HEIGHT); |
- vy = 0; |
- vx = BALL_VELX + myrand(9); |
- tx = 0; |
- ty = 0; |
- dt = ((float)PERIOD_BALL)/100000; |
- |
- while (1) { |
- y = y0 + vy*ty - .5*G*ty*ty; |
- x = x0 + vx * tx; |
- |
- if (y < 0) { |
- y = 0; |
- |
- if (vy == 0.0) |
- vy = vy0; |
- else if (vy < BALL_VYMIN) |
- vy = vy0 * (1.0 - myrand(50)/100.0); |
- else |
- vy = 0.9 * vy; |
- |
- ty = 0.0; |
- y0 = 0; |
- } |
- |
- if (x > BALL_XMAX) { |
- tx = 0.0; |
- x0 = BALL_XMAX; |
- vx = -vx; |
- x = x0 + vx * tx; |
- } |
- |
- if (x < BALL_XMIN) { |
- tx = 0.0; |
- x0 = BALL_XMIN; |
- vx = -vx; |
- x = x0 + vx * tx; |
- } |
- |
- mutex_lock(&mutex); |
- grx_disc(ox, oy, R, 0); |
- ox = x; |
- oy = BALL_Y - y; |
- mutex_unlock(&mutex); |
- |
- if (ballexit && i!=0xFFFF) { |
- npc--; |
- return 0; |
- } |
- |
- mutex_lock(&mutex); |
- grx_disc(ox, oy, R, i); |
- mutex_unlock(&mutex); |
- |
- my_delay(); |
- |
- ty += dt; |
- tx += dt; |
- task_endcycle(); |
- } |
-} |
- |
-void killball(KEY_EVT *k) |
-{ |
- ballexit = 1; |
-} |
- |
-void ballfun(KEY_EVT *k) |
-{ |
- SOFT_TASK_MODEL mp; |
- int r,g,b; |
- PID pid; |
- char palla_str[]="palla "; |
- |
- if (npc == BALL_MAX_P) return; |
- |
- ballexit = 0; |
- |
- r = 64 + myrand(190); |
- g = 64 + myrand(190); |
- b = 64 + myrand(190); |
- |
- itoa(npc,palla_str+5); |
- |
- soft_task_default_model(mp); |
- soft_task_def_level(mp,2); |
- soft_task_def_ctrl_jet(mp); |
- soft_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- soft_task_def_group(mp, BALL_GROUP); |
- soft_task_def_met(mp, WCET_BALL); |
- soft_task_def_period(mp,PERIOD_BALL); |
- soft_task_def_usemath(mp); |
- pid = task_create(palla_str, palla, &mp, NULL); |
- |
- if (pid != NIL) { |
- task_activate(pid); |
- npc++; |
- } |
-} |
- |
-void hardball() |
-{ |
- HARD_TASK_MODEL mp; |
- int r,g,b; |
- PID pid; |
- |
- r = 255; |
- g = 255; |
- b = 255; |
- |
- hard_task_default_model(mp); |
- hard_task_def_ctrl_jet(mp); |
- hard_task_def_arg(mp, (void *)rgb16(r,g,b)); |
- hard_task_def_wcet(mp, WCET_HARD_BALL); |
- hard_task_def_mit(mp,PERIOD_BALL); |
- hard_task_def_usemath(mp); |
- pid = task_create("pallaEDF", palla, &mp, NULL); |
- if (pid == NIL) { |
- sys_shutdown_message("Could not create task <pallaEDF>"); |
- sys_end(); |
- return; |
- } |
- else |
- task_activate(pid); |
-} |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* MAIN process */ |
-/*--------------------------------------------------------------*/ |
- |
-void scenario_ball() |
-{ |
- grx_text("Noise", 0, 45 /*BALL_Y-BALL_HEIGHT-15*/, rgb16(0,0,255), black); |
- grx_line(0,55,383,55,red); |
- grx_rect(BALL_XMIN-R-1, BALL_Y-BALL_HEIGHT-R-1, |
- BALL_XMAX+R+1, BALL_Y+R+1, rgb16(0,200,0)); |
-} |
- |
-void init_ball(void) |
-{ |
- KEY_EVT k; |
- |
- hardball(); |
- |
- k.flag = 0; |
- k.scan = KEY_SPC; |
- k.ascii = ' '; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,ballfun,FALSE); |
- |
- k.flag = 0; |
- k.scan = KEY_BKS; |
- k.ascii = ' '; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,killball,FALSE); |
-} |
- |
-/*--------------------------------------------------------------*/ |
Index: tags/rel_1_4_rc1/jumpball/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/jumpball/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/jumpball/makefile (nonexistent) |
@@ -1,24 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= ecp ern rrp rrn |
- |
-include $(BASE)/config/example.mk |
- |
-ecp: |
- make -f $(SUBMAKE) APP=ecp INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
-ern: |
- make -f $(SUBMAKE) APP=ern INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
-rrp: |
- make -f $(SUBMAKE) APP=rrp INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
-rrn: |
- make -f $(SUBMAKE) APP=rrn INIT= OTHEROBJS="demo.o ball.o jetctrl.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
Index: tags/rel_1_4_rc1/newtrace/udp/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/udp/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/udp/initfile.c (nonexistent) |
@@ -1,161 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * Authors : Mauro Marinoni <mauro.marinoni@unipv.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
- |
-#include <kernel/kern.h> |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/intdrive.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = 1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- PCI26_init(); |
- INPUT26_init(); |
- |
- /*keyb_def_map(kparms, KEYMAP_IT);*/ |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB26_init(&kparms); |
- |
- return 0; |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- sys_abort_shutdown(0); |
- |
- return NULL; |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-void call_shutdown_task(void *arg) { |
- |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
Index: tags/rel_1_4_rc1/newtrace/udp/udptrace.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/udp/udptrace.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/udp/udptrace.c (nonexistent) |
@@ -1,76 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <kernel/kern.h> |
-#include <FTrace_chunk.h> |
-#include <FTrace_udp.h> |
-#include <tracer.h> |
- |
-int main(int argc, char **argv) |
-{ |
- |
- long long i; |
- |
- int a,b,c; |
- struct timespec start,end,diff; |
- SYS_FLAGS f; |
- |
- a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
- b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
- c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
- |
- FTrace_chunk_link(a,b); |
- FTrace_chunk_link(b,c); |
- |
- FTrace_actual_chunk_select(a); |
- |
- kern_gettime(&start); |
- FTrace_enable(); |
- |
- for (i=0;i<1000000000;i++); |
- |
- TRACER_LOGEVENT(FTrace_EVT_next_chunk,0,0); |
- |
- f = kern_fsave(); |
- __asm__("cpuid":::"eax","ebx","ecx","edx"); |
- FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1,0); |
- FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2,0); |
- FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3,0); |
- FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,4,0); |
- FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,5,0); |
- __asm__("cpuid":::"eax","ebx","ecx","edx"); |
- kern_frestore(f); |
- |
- TRACER_LOGEVENT(FTrace_EVT_ipoint,6,0); |
- |
- for (i=0;i<1000000000;i++); |
- |
- FTrace_disable(); |
- kern_gettime(&end); |
- |
- SUBTIMESPEC(&end,&start,&diff); |
- |
- cprintf("Logged Time %d s %d us\n",(int)diff.tv_sec,(int)diff.tv_nsec/1000); |
- |
- FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1"); |
- |
- FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
- FTrace_send_chunk(b, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/newtrace/udp/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/udp/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/udp/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = udptrace |
- |
-include $(BASE)/config/example.mk |
- |
-udptrace: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=udptrace INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __NET__" |
- |
Index: tags/rel_1_4_rc1/newtrace/nosave/nosave.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/nosave/nosave.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/nosave/nosave.c (nonexistent) |
@@ -1,58 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <kernel/kern.h> |
-#include <tracer.h> |
- |
-int main(int argc, char **argv) |
-{ |
- |
- long long i; |
- |
- int a,b,c; |
- struct timespec start,end,diff; |
- |
- a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
- b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
- c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
- |
- FTrace_chunk_link(a,b); |
- FTrace_chunk_link(b,c); |
- |
- FTrace_actual_chunk_select(a); |
- |
- kern_gettime(&start); |
- FTrace_enable(); |
- |
- for (i=0;i<1000000000;i++); |
- |
- TRACER_LOGEVENT(FTrace_EVT_next_chunk,0,0); |
- |
- for (i=0;i<1000000000;i++); |
- |
- FTrace_disable(); |
- kern_gettime(&end); |
- |
- SUBTIMESPEC(&end,&start,&diff); |
- |
- cprintf("Logged Time %d s %d us\n",(int)diff.tv_sec,(int)diff.tv_nsec/1000); |
- |
- FTrace_chunk_dump(a); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/newtrace/nosave/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/nosave/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/nosave/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = nosave |
- |
-include $(BASE)/config/example.mk |
- |
-nosave: |
- make -f $(SUBMAKE) BASE=$(BASE) APP=nosave INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __NET__" |
- |
Index: tags/rel_1_4_rc1/newtrace/nosave/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/nosave/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/nosave/initfile.c (nonexistent) |
@@ -1,61 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 0); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/newtrace/readme |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/readme (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/readme (nonexistent) |
@@ -1,13 +0,0 @@ |
-This directory contains a set of sub directories containing all the tracer |
-examples and utilities. |
- |
-Here a short description of the contents |
- |
-utils - some small utilities: |
- |
- udpdump - save on a file the logged events sent through network |
- |
-udp - a small application that sends its trace data through the network |
- |
-nosave - a simple tracer implementation without saving logged events |
- |
Index: tags/rel_1_4_rc1/newtrace/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/makefile (nonexistent) |
@@ -1,10 +0,0 @@ |
-.PHONY: all clean |
- |
-all: |
- make -C udp |
- make -C nosave |
- |
-clean: |
- make -C udp clean |
- make -C nosave clean |
- |
Index: tags/rel_1_4_rc1/newtrace/utils/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/utils/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/utils/makefile (nonexistent) |
@@ -1,28 +0,0 @@ |
-# |
-# util_linux -> compiles the tracer utilities under Linux |
-# |
- |
-ifndef BASE |
-BASE=../../.. |
-endif |
- |
-.PHONY: util_dos util_linux clean |
- |
-all: |
- @echo Targets: util_dos util_linux clean |
- @echo Note: udpdump and list are available only under linux |
- |
-util_linux: udpdump list |
- |
-udpdump: udpdump.c |
- gcc -Wimplicit-function-declaration -Wall -ggdb\ |
- -I$(BASE)/include/trace -I$(BASE)/oslib udpdump.c -o udpdump |
- |
-list: list.c |
- gcc -Wimplicit-function-declaration -Wall -ggdb\ |
- -I$(BASE)/include/trace -I$(BASE)/oslib list.c -o list |
- |
-clean: |
- rm -rf *.o udpdump list |
- |
- |
Index: tags/rel_1_4_rc1/newtrace/utils/udpdump.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/utils/udpdump.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/utils/udpdump.c (nonexistent) |
@@ -1,134 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <netinet/in.h> |
- |
-#include <sys/socket.h> |
-#include <netinet/in.h> |
-#include <arpa/inet.h> |
-#include <netdb.h> |
-#include <stdio.h> |
-#include <unistd.h>/* close() */ |
-#include <stdlib.h> |
-#include <signal.h> |
-#include <string.h> |
- |
-#define SERVER_PORT 20000 |
-#define MAX_MSG 10000 |
- |
-struct tracer_udp_header { |
- char id[12]; |
- unsigned int pkt_number; |
- unsigned int events; |
- unsigned int size; |
-}; |
- |
-FILE *output_file; |
- |
-int miss; |
- |
-void close_and_exit() |
-{ |
- |
- printf("Closing...\n"); |
- |
- if (miss == 1) printf("Possible error receiving packets !\n"); |
- |
- fclose(output_file); |
- |
- exit(0); |
- |
-} |
- |
-int main(int argc, char *argv[]) |
-{ |
- int sd, rc, n, cliLen,count; |
- struct sockaddr_in cliAddr, servAddr; |
- char msg[MAX_MSG]; |
- |
- struct tracer_udp_header *pkt_head = (struct tracer_udp_header *)(msg); |
- |
- if (argc < 2) { |
- printf("%s: Enter the output file name [%s filename]\n",argv[0],argv[0]); |
- exit(1); |
- } |
- |
- // socket creation |
- sd = socket(AF_INET, SOCK_DGRAM, 0); |
- if(sd < 0) { |
- printf("%s: cannot open socket \n",argv[0]); |
- exit(1); |
- } |
- |
- output_file = fopen(argv[1],"w+b"); |
- if (output_file == NULL) { |
- printf("%s: Cannot open the file\n",argv[0]); |
- exit(1); |
- } |
- |
- // bind local server port |
- servAddr.sin_family = AF_INET; |
- |
- servAddr.sin_addr.s_addr = htonl(INADDR_ANY); |
- servAddr.sin_port = htons(SERVER_PORT); |
- |
- rc = bind (sd, (struct sockaddr *)&servAddr,sizeof(servAddr)); |
- if(rc < 0) { |
- printf("%s: cannot bind port number %d \n", |
- argv[0], SERVER_PORT); |
- exit(1); |
- } |
- |
- signal(SIGINT, close_and_exit); |
- |
- count = 1; |
- miss = 0; |
- |
- while(1) { |
- |
- printf("Wait packet...\n"); |
- |
- // receive message |
- cliLen = sizeof(cliAddr); |
- n = recvfrom(sd, msg, MAX_MSG, 0,(struct sockaddr *)&cliAddr, &cliLen); |
- |
- if (strncmp(pkt_head->id,"TRACER",6)) continue; |
- |
- printf("Received %d, length %d(%d), %d tracer events.\n", |
- pkt_head->pkt_number, n, pkt_head->size, pkt_head->events); |
- |
- if (pkt_head->pkt_number != count) { |
- printf("Miss Packet !!!\n"); |
- miss = 1; |
- } |
- |
- if (n > 0) { |
- |
- count++; |
- |
- fwrite((void *)(msg+sizeof(struct tracer_udp_header)),n-sizeof(struct tracer_udp_header),1,output_file); |
- |
- } |
- |
- } |
- |
- fclose(output_file); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_4_rc1/newtrace/utils/list.c |
=================================================================== |
--- tags/rel_1_4_rc1/newtrace/utils/list.c (revision 1476) |
+++ tags/rel_1_4_rc1/newtrace/utils/list.c (nonexistent) |
@@ -1,88 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-#include <stdio.h> |
-#include <unistd.h> |
-#include <stdlib.h> |
-#include <string.h> |
- |
-#define READ_BUFFER 2000 |
-#define DELTA_BUFFER 100 |
- |
-int main(int argc, char *argv[]) |
-{ |
- |
- char buffer[READ_BUFFER+DELTA_BUFFER]; |
- void *p, *last; |
- int n,delta,size; |
- |
- unsigned long long ev = 0; |
- |
- FILE *input_file; |
- |
- if (argc < 2) { |
- printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]); |
- exit(1); |
- } |
- |
- input_file = fopen(argv[1],"rb"); |
- |
- last = buffer + READ_BUFFER; |
- |
- while(!feof(input_file)) { |
- |
- //move remaining byte |
- delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last); |
- if (delta > 0) memcpy(buffer,last,delta); |
- |
- n = fread(buffer+delta,1,READ_BUFFER+10,input_file); |
- fseek(input_file,-(delta+10),SEEK_CUR); |
- |
- p = buffer; |
- |
- while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) && |
- (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) { |
- |
- printf("%08d Type = %02x ",(unsigned int)ev,*(unsigned short int *)(p)); |
- |
- printf("TSC = %08x:%08x",*(unsigned int *)(p+4),*(unsigned int *)(p+8)); |
- |
- size = 16; |
- |
- printf(" Par1 = %d",*(unsigned short int *)(p+2)); |
- printf(" Par2 = %d\n",*(unsigned int *)(p+12)); |
- |
- ev++; |
- |
- p += 16; |
- |
- if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
- |
- last = p; |
- |
- } |
- |
- if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
- |
- } |
- |
- fclose(input_file); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_4_rc1/base/initgraph.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/initgraph.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/initgraph.c (nonexistent) |
@@ -1,198 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/hardcbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- HCBS_register_level(HCBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/base/ipcidemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/ipcidemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/ipcidemo.c (nonexistent) |
@@ -1,133 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/hardcbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/intdrive.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "drivers/shark_linuxc26.h" |
-#include "drivers/shark_pci26.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- HCBS_register_level(HCBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- return 0; |
- |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) { |
- |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
- |
-} |
Index: tags/rel_1_4_rc1/base/fly.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/fly.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/fly.c (nonexistent) |
@@ -1,195 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: fly.c,v 1.8 2004-04-23 07:57:33 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.8 $ |
- Last update: $Date: 2004-04-23 07:57:33 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* SIMULATION OF RANDOM FLIES */ |
-/*--------------------------------------------------------------*/ |
- |
-#include <kernel/kern.h> |
-#include <stdlib.h> |
-#include <math.h> |
- |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define YMENU 10 /* menu level */ |
-#define XMIN 50 |
-#define XMAX 600 |
-#define YMIN 100 |
-#define YMAX 450 |
-#define VEL 5 /* linear velocity (def. = 5) */ |
-#define ANG 30 /* angolo massimo sterzata (30) */ |
-#define D 3 /* raggio mosca */ |
-#undef ESC |
-#define ESC 27 /* ASCII code of ESCAPE key */ |
-#define MAX_P 35 /* max number of flies */ |
-#define FLYGROUP 1 |
- |
-double tick = 1.0; /* system tick = 1 ms */ |
-int fly_period = 40000; /* task period */ |
-int fly_wcet = 1000; /* task wcet */ |
-PID pid; |
- |
-/*--------------------------------------------------------------*/ |
- |
-void draw_fly(int x, int y, int c) |
-{ |
- grx_disc(x, y, D, c); |
-} |
- |
-/******************************************************************/ |
- |
-TASK fly(void *arg) |
-{ |
-int x, y; |
-int ox, oy; |
-int dx, dy, da; |
-int teta, col,red; |
-int outx, outy; |
-double r; |
-int i = (int)arg; |
- |
- x = ox = (XMIN+XMAX)/2; |
- y = oy = (YMIN+YMAX)/2; |
- teta = 0; |
- red = 100+10*i; |
- if (red > 255) red = 255; |
- col = rgb16(red,0,50); /* colore fly */ |
- |
- while (1) { |
- |
- da = rand()%(2*ANG) - ANG; /* da = [-ANG,ANG] */ |
- teta += da; |
- |
- if (teta > 360) teta -= 360; |
- if (teta < 0) teta += 360; |
- r = (double)teta * PI / 180.; |
- |
- dx = (float)(VEL * cos(r)); |
- dy = (float)(VEL * sin(r)); |
- x += dx; |
- y += dy; |
- |
- outx = (x >= XMAX) || (x <= XMIN); |
- outy = (y >= YMAX) || (y <= YMIN); |
- |
- if (outx || outy) { |
- x = x - dx; |
- y = y - dy; |
- if (outx) teta = 180 - teta; |
- if (outy) teta = -teta; |
- if (teta > 360) teta -= 360; |
- if (teta < 0) teta += 360; |
- r = (double)teta * PI / 180.; |
- |
- dx = (float)(VEL * cos(r)); |
- dy = (float)(VEL * sin(r)); |
- |
- x += dx; |
- y += dy; |
- } |
- |
- draw_fly(ox, oy, 0); |
- draw_fly(x, y, col); |
- ox = x; oy = y; |
- |
- task_endcycle(); |
- } |
-} |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- HARD_TASK_MODEL m; |
- |
- char c; /* character from keyboard */ |
- int i = 0; /* number of tasks created */ |
- TIME seme; /* used to init the random seed */ |
- |
- /* The scenario */ |
- grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, rgb16(255,255,255)); |
- grx_text("Simulation of Random Flies", XMIN, YMENU+10, rgb16(255,255,255), 0); |
- grx_text("SPACE create a fly" , XMIN, YMENU+20, rgb16(255,255,255), 0); |
- grx_text("ESC exit to DOS" , XMIN, YMENU+30, rgb16(255,255,255), 0); |
- |
- /* The program waits a space to create a fly */ |
- c = keyb_getch(BLOCK); |
- |
- /* randomize!!!! */ |
- seme = sys_gettime(NULL); |
- srand(seme); |
- |
- do { |
- if ((c == ' ') && (i < MAX_P)) { |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, fly_wcet); |
- hard_task_def_mit (m, fly_period); |
- hard_task_def_group (m, FLYGROUP); |
- hard_task_def_usemath (m); |
- pid = task_create("fly", fly, &m, NULL); |
- if (pid == NIL) { |
- sys_shutdown_message("Could not create task <fly>"); |
- sys_end(); |
- return 0; |
- } |
- task_activate(pid); |
- i++; |
- } |
- c = keyb_getch(BLOCK); |
- |
- } while (c != ESC); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
- |
-/*--------------------------------------------------------------*/ |
Index: tags/rel_1_4_rc1/base/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/base/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/base/makefile (nonexistent) |
@@ -1,95 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = hello sig time preempt |
-PROGS += aster aster1 aster2 aster3 aster4 aster5 aster6 aster7 aster8 |
-PROGS += pcidemo |
-PROGS += jointest condtest intsem semdemo pidemo pcdemo srpdemo mdemo |
-PROGS += ego fly cabs |
- |
-include $(BASE)/config/example.mk |
- |
-# Text applications |
-hello: |
- make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT= |
- |
-time: |
- make -f $(SUBMAKE) APP=time INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT= |
- |
-sig: |
- make -f $(SUBMAKE) APP=sig INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT= |
- |
-preempt: |
- make -f $(SUBMAKE) APP=preempt INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-semdemo: |
- make -f $(SUBMAKE) APP=semdemo INIT= OTHEROBJS="isemdemo.o" OTHERINCL= SHARKOPT= |
- |
-pidemo: |
- make -f $(SUBMAKE) APP=pidemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-pcdemo: |
- make -f $(SUBMAKE) APP=pcdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-srpdemo: |
- make -f $(SUBMAKE) APP=srpdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-mdemo: |
- make -f $(SUBMAKE) APP=mdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-aster: |
- make -f $(SUBMAKE) APP=aster INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-aster1: |
- make -f $(SUBMAKE) APP=aster1 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT= |
- |
-aster2: |
- make -f $(SUBMAKE) APP=aster2 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT= |
- |
-aster3: |
- make -f $(SUBMAKE) APP=aster3 INIT= OTHEROBJS="iaster3.o" OTHERINCL= SHARKOPT= |
- |
-aster4: |
- make -f $(SUBMAKE) APP=aster4 INIT= OTHEROBJS="iaster4.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-aster5: |
- make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-aster6: |
- make -f $(SUBMAKE) APP=aster6 INIT= OTHEROBJS="iaster6.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-aster7: |
- make -f $(SUBMAKE) APP=aster7 INIT= OTHEROBJS="iaster7.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-aster8: |
- make -f $(SUBMAKE) APP=aster8 INIT= OTHEROBJS="iaster8.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__" |
- |
-pcidemo: |
- make -f $(SUBMAKE) APP=pcidemo INIT= OTHEROBJS="ipcidemo.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__" |
- |
-jointest: |
- make -f $(SUBMAKE) APP=jointest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-condtest: |
- make -f $(SUBMAKE) APP=condtest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-intsem: |
- make -f $(SUBMAKE) APP=intsem INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT= |
- |
-# Graphical applications |
- |
-ego: |
- make -f $(SUBMAKE) APP=ego INIT= OTHEROBJS="initgraph.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
-fly: |
- make -f $(SUBMAKE) APP=fly INIT= OTHEROBJS="initgraph.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
-cabs: |
- make -f $(SUBMAKE) APP=cabs INIT= OTHEROBJS="initgraph.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
Index: tags/rel_1_4_rc1/base/cabs.dat |
=================================================================== |
--- tags/rel_1_4_rc1/base/cabs.dat (revision 1476) |
+++ tags/rel_1_4_rc1/base/cabs.dat (nonexistent) |
@@ -1,11 +0,0 @@ |
----------------------------------------------------- |
-system tick (ms): 1 |
----------------------------------------------------- |
- |
-task periods (ticks) |
----------------------------------------------------- |
-producer 1: 200 consumer 1: 400 |
-producer 2: 100 consumer 2: 400 |
-producer 3: 300 consumer 3: 150 |
-producer 4: 800 consumer 4: 200 |
----------------------------------------------------- |
Index: tags/rel_1_4_rc1/base/aster1.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster1.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster1.c (nonexistent) |
@@ -1,174 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster1.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $ |
- |
- this is a reduced verion of the classic Hartik demo Aster. |
- |
- It uses: |
- - EDF module |
- . periodic tasks |
- - an high number of task executing concurrently |
- |
- The demo ends after 6 seconds. |
- |
-*/ |
- |
-/* |
- Well, this is only a stupid demo which intend to show many |
- HARTIK+ capabilities; the application is structured in the followig |
- way: there is an ASTER task wich randomly creates some ASTEROID tasks |
- which are displayed into the first window; each task is HARD/PERIODIC |
- and auto-kills itself when it reaches the window end! |
- Finally a CLOCK task is implemented to test system clock. |
- Please note that usually the HARTIK+ application is made up of a task |
- group which interacts among them, while the main() function, which |
- became a task itself when the kernel is activated, is suspended until |
- the system is ready to terminate; the MAIN task can also be used to make |
- other background activities, but it should not be killed; when the |
- application terminates, the control is passed to MAIN which kills |
- everybody, shut down the system and can handle other operations using |
- the services available with the previou operating system (I.E. the DOS). |
- If you need to manage sudden abort/exception you should install your own |
- exception handler and raise it through the exc_raise() primitive to |
- make the system abort safely! |
- Remember that the exit functions posted through sys_atexit() will be |
- executed in both cases, to allow clean system shutdown. |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 67 |
-#define ASTER_MAX 90 |
- |
-TASK asteroide(void) |
-{ |
- int i = 1; |
- int y = rand() % 20 + 1; |
- while (i < ASTER_LIM) { |
- puts_xy(i,y,WHITE,"*"); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-DWORD taskCreated = 0; |
- |
-TASK aster(void) |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,500); |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 50) - 25; |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (50+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- taskCreated++; |
- task_activate(p); |
- num_aster++; |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2; |
- HARD_TASK_MODEL m; |
- struct timespec t; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,10000); |
- hard_task_def_wcet(m,2000); |
- hard_task_def_group(m,1); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/jointest.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/jointest.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/jointest.c (nonexistent) |
@@ -1,214 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: jointest.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $ |
- |
- This test verify the correctness of the task_join primitive. (that |
- function is the same as pthread_join... someday I will change the |
- names...) |
- |
- There are 4 taks, J1, J2, J3, are created as joinable, J4 as detached |
- |
- The main task: |
- Creates J1 and J2, locks m1 (a PI mitex), creates C3. |
- at t=0.8 sec it calls a task_join on J3 (that returns EDEADLK), |
- it unlocks m1, then it makes task_join on J3 another time. |
- Next it creates J4 as detached and finally it does a task_join on J4 |
- (that returns EINVAL). |
- |
- J1: |
- at t=0.2 sec it calls task_join on J2, the it ends. |
- |
- J2: |
- it simply waits t=0.4 sec and it ends. |
- |
- J3: |
- First, it calls task_join on J1. |
- Then, at t=0.6 sec it locks m1, then unlocks it |
- |
- J4: |
- it simply waits t=1 sec and it ends. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-PID j0, j1, j2, j3, j4; |
-mutex_t m1; |
- |
-TASK J1() |
-{ |
- int err; |
- void *ret; |
- |
- cprintf("J1: started, waiting 0.2 sec\n"); |
- |
- while (sys_gettime(NULL) < 200000); |
- |
- cprintf("J1: 0.2 sec reached, joining J2\n"); |
- |
- err = task_join(j2, &ret); |
- |
- cprintf("J1: join J2 returns %d error %d, exiting\n", |
- (int)ret,err); |
- return (void *)11; |
-} |
- |
-TASK J2() |
-{ |
- cprintf("J2: started, waiting 0.4 sec\n"); |
- |
- while (sys_gettime(NULL) < 400000); |
- |
- cprintf("J2: 0.4 sec reached, exiting\n"); |
- |
- return (void *)22; |
-} |
- |
-TASK J3() |
-{ |
- int err; |
- void *ret; |
- |
- cprintf("J3: started, joining J1\n"); |
- |
- err = task_join(j1, &ret); |
- |
- cprintf("J3: join J1 returns %d error %d, waiting 0.6sec\n", (int)ret, err); |
- |
- while (sys_gettime(NULL) < 600000); |
- |
- cprintf("J1: 0.6 sec reached, locking m1\n"); |
- |
- mutex_lock(&m1); |
- |
- cprintf("J3: locked m1, unlocking m1\n"); |
- |
- mutex_unlock(&m1); |
- |
- cprintf("J3: unlocked m1, exiting\n"); |
- |
- return (void *)33; |
-} |
- |
-TASK J4() |
-{ |
- cprintf("J4: started, waiting 1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J4: 1 sec reached, exiting\n"); |
- |
- return (void *)44; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- |
- PI_mutexattr_t a; |
- |
- int err; |
- void *ret; |
- |
- struct timespec t; |
- |
- j0 = exec_shadow; |
- nrt_task_default_model(m); |
- nrt_task_def_joinable(m); |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- |
- |
- /* --------------------------------------------------------------------- |
- Let's go !!!! |
- --------------------------------------------------------------------- */ |
- |
- cprintf("main: creating J1,J2,J3, locking m1\n"); |
- |
- j1 = task_create("J1", J1, &m, NULL); |
- if (j1 == NIL) { cprintf("Can't create J1 task...\n"); return 1; } |
- task_activate(j1); |
- |
- j2 = task_create("J2", J2, &m, NULL); |
- if (j2 == NIL) { cprintf("Can't create J2 task...\n"); return 1; } |
- task_activate(j2); |
- |
- mutex_lock(&m1); |
- |
- j3 = task_create("J3", J3, &m, NULL); |
- if (j3 == NIL) { cprintf("Can't create J3 task...\n"); return 1; } |
- task_activate(j3); |
- |
- cprintf("main: waiting t=0.8 sec\n"); |
- |
- while (sys_gettime(NULL) < 800000); |
- |
- err = task_join(j3, NULL); |
- |
- cprintf("main: join J3 error %d, unlocking m1\n",err); |
- |
- mutex_unlock(&m1); |
- |
- err = task_join(j3, &ret); |
- |
- cprintf("main: join J3 returns %d error %d, unlocked m1, creating J4\n", |
- (int)ret,err); |
- |
- nrt_task_def_unjoinable(m); |
- j4 = task_create("J4", J4, &m, NULL); |
- if (j4 == NIL) { cprintf("Can't create J4 task...\n"); return 1; } |
- |
- task_activate(j4); |
- |
- err = task_join(j4,&ret); |
- |
- cprintf("main: join J4 returns %d error %d, exiting\n", (int)ret, err); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/base/aster2.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster2.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster2.c (nonexistent) |
@@ -1,241 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster2.c,v 1.4 2004-04-19 14:48:04 giacomo Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- It checks: |
- - jet functions |
- - The EDF level with many task, with almost full bandwidth used |
- |
-*/ |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-// first numbers for wcet and periods are for a 486/25, the others for a |
-// celeron 366 |
- |
-#define PER_WCET 13000 /*6200*/ |
-#define CLOCK_WCET 1200 /* 100*/ |
-#define ASTER_WCET 1200 /* 100*/ |
- |
-#define ASTER_MEAN_PERIOD 64 /*64*/ |
- |
-#define END_TEST_TIME 60 |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000; //10000; // 5000 + rand()%5000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = ASTER_MEAN_PERIOD; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- struct timespec t; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < END_TEST_TIME); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
- |
- |
- |
Index: tags/rel_1_4_rc1/base/aster3.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster3.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster3.c (nonexistent) |
@@ -1,300 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster3.c,v 1.5 2004-04-19 14:48:04 giacomo Exp $ |
- |
- Test Number 10 (A): |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on aster2.c, with the use of TBS to serve a set of aperiodic |
- tasks. |
- |
- There are APER_MAX tasks sleeping, and when an asteroide task finish |
- the current activation, it activate also an aperiodic task chosen |
- randomly (if the task chosen is already active, the task_activate do |
- nothing!) |
- |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define APER_MAX 8 |
- |
-/* first numbers runs on a pentium 133, second numbers on a celeron 366 */ |
-#define PER_WCET 30000 /* 6200 */ |
-#define APER_WCET 50000 /* 18400 */ |
-#define CLOCK_WCET 1000 /* 200 */ |
-#define ASTER_WCET 1000 /* 200 */ |
-#define MIN_PERIOD 200 /* 64, in ms */ |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = MIN_PERIOD; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- task_endcycle(); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2;//,p3,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- int i; |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_def_level(m_aper, 3); |
- aper_table[0] = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (aper_table[0] == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- } |
- |
- for (i=1; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 3); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- } |
- } |
- |
- |
- group_activate(1); |
- |
- { |
- struct timespec t; |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 60); |
- } |
- |
- sys_end(); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/aster4.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster4.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster4.c (nonexistent) |
@@ -1,389 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster4.c,v 1.3 2004-04-19 14:48:04 giacomo Exp $ |
- |
- Test Number 13 (D): |
- |
- this is a part of the classic Hartik demo Aster, and it is based on aster 3. |
- |
- The demo creates: |
- - a set of TBS tasks assigned to 2 TBS servers initialized with different bandwidth. |
- |
- - a set of periodic tasks, just to make noise (function asteroide) |
- |
- - a set of CBS tasks that are created to fill the available free |
- bandwidth (function soft_aster) |
- |
- - a few service task (the one that creates the CBS tasks (aster), a clock, |
- JET info visualization |
- |
- - a set of never ending "system tasks" that simulate a device driver |
- task that will end only at shutdown (function aper_asteroid) |
- |
- - a keyboard task that will execute an hook to terminate the system |
- |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-// These numbers works on a Pentium 133 */ |
-#define PER_WCET 25000 |
-#define APER_WCET 53000 |
-#define CLOCK_WCET 1000 |
-#define ASTER_WCET 1000 |
-#define SOFT_MET 6300 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = 1; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- /* create a set of periodic tasks, just to make noise */ |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- hard_task_def_mit(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 64; |
- |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(5)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(5)); |
- task_endcycle(); |
- } |
-} |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 || |
- (proc_table[p].pclass & 0xFF00) == HARD_PCLASS) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- if (proc_table[p].task_level == 5) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(4,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
-void endfun(KEY_EVT *k) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- KEY_EVT k; |
- |
- PID p1,p2,p3; |
- HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- int i; |
- |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- k.status = KEY_PRESSED; |
- keyb_hook(k, endfun, FALSE); |
- |
- clear(); |
- cprintf("Press ENTER to end the demo..."); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,1000); |
- soft_task_def_period(m_soft,100000); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("aster4.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("aster4.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- p3 = task_create("JetControl",jetcontrol,&m_soft,NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("aster4.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_system(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 3); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- sys_shutdown_message("aster4.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- return 0; |
- } |
- } |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/isemdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/isemdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/isemdemo.c (nonexistent) |
@@ -1,98 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: isemdemo.c,v 1.1 2002-11-11 08:22:45 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-11-11 08:22:45 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/sem.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/aster5.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster5.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster5.c (nonexistent) |
@@ -1,477 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster5.c,v 1.4 2004-04-19 14:48:04 giacomo Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 13 (d), and use the CBS to serve the periodic tasks. |
- |
- There are not periodic tasks, only CBS tasks. |
- |
- The tasks use a PI, NPP or NOP mutex to access the video memory. |
- |
- A flag (LONGSC) is provided to try long and short critical sections. |
- |
- This demo is really interesting because you can note the behavior of |
- the system, and the differences between the various protocols... |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
- |
-#include <drivers/shark_keyb26.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 6200 |
-#define APER_WCET 18400 |
-#define JET_WCET 10000 |
-#define JET_PERIOD 100000 |
- |
-#define APER_REP 22000 |
- |
-//PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 3000 /* 3000 12000 */ |
-#define CLOCK_WCET 400 /* 200 300*/ |
-#define ASTER_WCET 400 /* 200 300*/ |
-#else |
-#define SOFT_MET 80000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
-#ifdef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- |
- // task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = c; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = 1; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- // task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- // HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- /* periodic_task_default_model(m,0,PER_WCET); |
- periodic_task_def_ctrl_jet(m); |
- for (x=0; x<PER_MAX; x++) { |
- r = (rand() % 200); |
- periodic_task_def_period(m, (64+r)*1000); |
- p = task_create("per",asteroide,&m,NULL); |
- if (p!=-1) task_activate(p); |
- } |
- */ |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- mutex_unlock(&m1); |
- |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- |
- mutex_unlock(&m1); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(2)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 2) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³p%-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)proc_table[p].status, (int)proc_table[p].shadow, (int)proc_table[p].timespec_priority.tv_sec,(int)proc_table[p].timespec_priority.tv_nsec/1000 , (int)last[3], (int)last[4]); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3;//,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- // NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- // int i; |
- struct timespec fineprg; |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_t a; |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
-#endif |
- |
- KEY_EVT emerg; |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- emerg.status = KEY_PRESSED; |
- keyb_hook(emerg,fine,FALSE); |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,100000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- // nrt_task_default_model(m_nrt); |
- // nrt_task_def_group(m_nrt,1); |
- // nrt_task_def_ctrl_jet(m_nrt); |
- |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,JET_PERIOD); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- // p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- p3 = task_create("JetControl",jetcontrol,&m_soft,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- return 0; |
- } |
- /* |
- aperiodic_task_default_model(m_aper,APER_WCET); |
- aperiodic_task_def_ctrl_jet(m_aper); |
- aperiodic_task_def_system(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- aperiodic_task_def_level(m_aper, i/4 + 2); |
- aperiodic_task_def_arg(m_aper, (i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- perror("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- l1_exit(-1); |
- } |
- } |
- */ |
- task_nopreempt(); |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_default(a); |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
-#endif |
- |
- mutex_init(&m1, &a); |
- |
- fineprg.tv_sec = 1800; |
- fineprg.tv_nsec = 0; |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/aster6.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster6.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster6.c (nonexistent) |
@@ -1,447 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster6.c,v 1.5 2004-04-21 14:55:05 giacomo Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 17 (h), and the JobControl Task uses an |
- SOFT_TASK_MODEL served by a polling server |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
- |
-#include <drivers/shark_keyb26.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 6200 |
-#define APER_WCET 18400 |
-#define JET_WCET 10000 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-//#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 3000 /* 12000 */ |
-#define CLOCK_WCET 200 /* 300*/ |
-#define ASTER_WCET 200 /* 300*/ |
-#else |
-#define SOFT_MET 80000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
-#ifdef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = c; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
-#ifdef LONGSC |
- mutex_lock(&m1); |
-#endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
-#ifndef LONGSC |
- mutex_unlock(&m1); |
-#endif |
- } |
- s[0] = 1; |
-#ifndef LONGSC |
- mutex_lock(&m1); |
-#endif |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- // HARD_TASK_MODEL m; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- mutex_unlock(&m1); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(3)); |
- |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(1)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(3)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 3) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- // p, sum/(nact==0 ? 1 : nact), max, nact, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , last[3], last[4]); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- // NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- // int i; |
- struct timespec fineprg; |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_t a; |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
-#endif |
- |
- KEY_EVT emerg; |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- emerg.status = KEY_PRESSED; |
- keyb_hook(emerg,fine,FALSE); |
- |
- clear(); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,100000); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- // nrt_task_default_model(m_nrt); |
- // nrt_task_def_group(m_nrt,1); |
- // nrt_task_def_ctrl_jet(m_nrt); |
- |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,100000); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- // p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL); |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- task_nopreempt(); |
- |
-#ifdef PIMUTEX |
- PI_mutexattr_default(a); |
-#endif |
- |
-#ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
-#endif |
- |
-#ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
-#endif |
- |
- mutex_init(&m1, &a); |
- |
- fineprg.tv_sec = 20; |
- fineprg.tv_nsec = 0; |
- kern_event_post(&fineprg,(void (*)(void *))fine,NULL); |
- group_activate(1); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/aster7.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster7.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster7.c (nonexistent) |
@@ -1,315 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster7.c,v 1.4 2004-04-21 14:55:05 giacomo Exp $ |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 10(A), and test the PS with RM. |
- |
- The JetControl is served by a dedicated Polling Server, too. |
- |
- There are APER_MAX tasks sleeping, and when an asteroide task finish |
- the current activation, it activate also an aperiodic task chosen |
- randomly (if the task chosen is already active, the task_activate do |
- nothing!) |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 15 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define APER_MAX 8 |
- |
-/* Pentium 133 / Celeron 366 */ |
-#define PER_WCET 25000 /* 7800 */ |
-#define APER_WCET 5500 /* 1400 */ |
-#define CLOCK_WCET 500 /* 200 */ |
-#define ASTER_WCET 500 /* 200 */ |
- |
-#define APER_REP 2200 |
- |
-PID aper_table[APER_MAX]; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- puts_xy(i,y,rand()%15+1,s); |
- } |
- s[0] = c; |
- puts_xy(i,y,rand()%15+1,s); |
- |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- } |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- HARD_TASK_MODEL m; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,PER_WCET); |
- hard_task_def_ctrl_jet(m); |
- |
- x = 200; |
- |
- srand(7); |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- hard_task_def_arg(m,(void *)((rand() % 7)+1)); |
- hard_task_def_mit(m, (x+r)*1000); |
- p = task_create("aaa",asteroide,&m,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc),errno); |
- } |
- else { |
- num_aster++; |
- printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(1)); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- kern_cli(); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- kern_sti(); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- kern_cli(); |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
- kern_sti(); |
- i++; |
- } |
- } |
-} |
- |
- |
-void fine(KEY_EVT *e) |
-{ |
- sys_end(); |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3; //,p4,p5,p6; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- int i; |
- |
- KEY_EVT emerg; |
- |
- clear(); |
- |
- cprintf("Press Alt-x to end the demo..."); |
- |
- //keyb_set_map(itaMap); |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- emerg.status = KEY_PRESSED; |
- keyb_hook(emerg,fine,FALSE); |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_mit(m,10000); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m,500000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_level(m_aper, 2); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_aperiodic(m_aper); |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- soft_task_def_wcet(m_aper,APER_WCET); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- for (i=0; i<APER_MAX; i++) { |
- soft_task_def_level(m_aper, i/4 + 4); |
- soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±')); |
- aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL); |
- if (aper_table[i] == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aper> ..."); |
- sys_end(); |
- return 0; |
- } |
- } |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/aster8.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster8.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster8.c (nonexistent) |
@@ -1,501 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster8.c,v 1.4 2004-04-21 14:55:05 giacomo Exp $ |
- |
- Test for Sporadic Server (ss): |
- |
- this is a part of the classic Hartik demo Aster. |
- |
- it is based on test 17 (h), and the JobControl Task uses an |
- SOFT_TASK_MODEL served by a sporadic server |
- There are two "dummy" tasks that increment a counter and print |
- the value. One uses a SOFT_TASK_MODEL served by sporadic server, |
- the other uses a NRT_TASK_MODEL handled by RR module. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/ss.h" |
- |
-#include <drivers/shark_keyb26.h> |
- |
-int num_aster = 0; |
-#define EDF_LEV 1 |
-#define CBS_LEV 2 |
-#define SS_LEV 3 |
- |
-#define ASTER_LIM 60 |
-#define DISPLAY_MAX 8 |
-#define ASTER_MAX 70 |
-#define STAT_Y 9 |
- |
-#define PER_MAX 5 |
-#define APER_MAX 8 |
- |
-#define PER_WCET 16000 |
-#define APER_WCET 22000 |
-#define JET_WCET 20000 |
- |
-#define APER_REP 22000 |
- |
-PID aper_table[APER_MAX]; |
- |
-mutex_t m1; |
- |
- |
-#define PIMUTEX |
-//#define PCMUTEX |
-//#define NPPMUTEX |
-//#define NOPMUTEX |
- |
-#define LONGSC |
- |
-#ifdef LONGSC |
-#define SOFT_MET 12000 /* 12000 */ |
-#define CLOCK_WCET 300 /* 300*/ |
-#define ASTER_WCET 300 /* 300*/ |
-#else |
-#define SOFT_MET 5000 /* 4500 */ |
-#define CLOCK_WCET 2000 /* 200*/ |
-#define ASTER_WCET 2000 /* 200*/ |
-#endif |
- |
-PID p1,p2,p3,p4,p5; |
- |
-TASK asteroide(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 10000; //8000 + rand()%2000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- #ifdef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- //num_aster--; |
-} |
- |
-TASK aper_asteroid(void *a) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- int c; |
- |
- char s[2]; |
- |
- c = (int)a; |
- s[0] = '*'; s[1] = 0; |
- |
- for (;;) { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = APER_REP; //8000 + rand()%2000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- s[0] = c; |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- mutex_lock(&m1); |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
-} |
- |
-TASK soft_aster(void) |
-{ |
- int i; |
- int y = rand() % 7 + 1; |
- |
- int load1,j; |
- |
- char s[2]; |
- |
- s[0] = '*'; s[1] = 0; |
- |
- /*for (;;)*/ { |
- i = 1; |
- while (i < ASTER_LIM) { |
- load1 = 1000 + rand()%9000; |
- #ifdef LONGSC |
- mutex_lock(&m1); |
- #endif |
- for (j=0; j<load1; j++) { |
- s[0] = '*' + rand() % 100; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- puts_xy(i,y,rand()%15+1,s); |
- #ifndef LONGSC |
- mutex_unlock(&m1); |
- #endif |
- } |
- s[0] = 1; |
- #ifndef LONGSC |
- mutex_lock(&m1); |
- #endif |
- //mutex_lock(&m1); |
- puts_xy(i,y,rand()%15+1,s); |
- mutex_unlock(&m1); |
- |
- task_activate(aper_table[rand()%APER_MAX]); |
- task_endcycle(); |
- |
- mutex_lock(&m1); |
- puts_xy(i,y,WHITE," "); |
- mutex_unlock(&m1); |
- i++; |
- } |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-TASK aster() |
-{ |
- PID p; |
- |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- int x; // adaptive bandwidth... |
- |
- srand(7); |
- |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,SOFT_MET); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- x = 128; //64; |
- |
- while (1) { |
- if (num_aster < ASTER_MAX) { |
- r = (rand() % 200); |
- |
- soft_task_def_period(m_soft, (x+r)*1000); |
- p = task_create("aaa",soft_aster,&m_soft,NULL); |
- if (p == -1) |
- { |
- if (x < 500 && errno != ENO_AVAIL_TASK) x += 1; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u err=%d", |
- iq_query_first(&freedesc), errno); |
- mutex_unlock(&m1); |
- } |
- else { |
- num_aster++; |
- mutex_lock(&m1); |
- printf_xy(62,3,WHITE,"adapt=%3u ",x); |
- mutex_unlock(&m1); |
- task_activate(p); |
- x /= 2; |
- if (x<50) x = 50; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- int s = 0, m = 0; |
- |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(EDF_LEV)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(CBS_LEV)); |
- printf_xy(62,5,WHITE,"CSss=%6d",SS_availCs(SS_LEV)); |
- mutex_unlock(&m1); |
- |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- mutex_lock(&m1); |
- printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster); |
- printf_xy(62,2,WHITE,"Uedf=%12u",EDF_usedbandwidth(EDF_LEV)); |
- printf_xy(62,4,WHITE,"Ucbs=%12u",CBS_usedbandwidth(CBS_LEV)); |
- printf_xy(62,5,WHITE,"CSss=%6d",SS_availCs(SS_LEV)); |
- mutex_unlock(&m1); |
- task_endcycle(); |
- } |
-} |
- |
- |
- |
-/* we consider the first ASTER_MAX + 2 tasks from the PID 2 |
- and plot on the screen the elapsed times... */ |
-TASK jetcontrol() |
-{ |
- int i; /* a counter */ |
- TIME sum, max, curr, last[5]; |
- int nact; |
- int j; /* the elements set by jet_gettable */ |
- PID p; |
- |
- |
- mutex_lock(&m1); |
- printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5"); |
- mutex_unlock(&m1); |
- |
- for (;;) { |
- for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) { |
- if (jet_getstat(p, &sum, &max, &nact, &curr) == -1 /*|| |
- (proc_table[p].pclass & 0xFF00) == APERIODIC_PCLASS || |
- (proc_table[p].pclass & 0xFF00) == PERIODIC_PCLASS*/ ) continue; |
- |
- for (j=0; j<5; j++) last[j] = 0; |
- jet_gettable(p, &last[0], 5); |
- mutex_lock(&m1); |
- if (proc_table[p].task_level == 2) |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)CBS_get_nact(2,p), (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
-// p, sum/(nact==0 ? 1 : nact), max, proc_table[p].avail_time, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , CBS_get_nact(2,p), last[4]); |
- else |
- printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d", |
- p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]); |
-// p, sum/(nact==0 ? 1 : nact), max, nact, proc_table[p].status, proc_table[p].shadow, proc_table[p].timespec_priority.tv_sec,proc_table[p].timespec_priority.tv_nsec/1000 , last[3], last[4]); |
- mutex_unlock(&m1); |
- i++; |
- task_activate(p3); |
- task_endcycle(); |
- } |
- } |
-} |
- |
-void fine(KEY_EVT *e) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-void mydummyaper(void) { |
- int i=0; |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(1,24,RED,"dummyAPER pid=%d: %d",p4,i++); |
- mutex_unlock(&m1); |
- task_activate(p4); |
- task_endcycle(); |
- } |
-} |
- |
-void mydummynrt(void) { |
- int i=0; |
- while(1) { |
- mutex_lock(&m1); |
- printf_xy(40,24,RED,"dummyNRT pid=%d: %d",p5,i++); |
- mutex_unlock(&m1); |
- } |
-} |
- |
-int main(int argc, char **argv) |
-{ |
-// PID p1,p2,p5; |
- HARD_TASK_MODEL m; |
- NRT_TASK_MODEL m_nrt; |
- SOFT_TASK_MODEL m_aper; |
- SOFT_TASK_MODEL m_soft; |
- |
- #ifdef PIMUTEX |
- PI_mutexattr_t a; |
- #endif |
- |
- #ifdef PCMUTEX |
- PC_mutexattr_t a; |
- #endif |
- |
- #ifdef NPPMUTEX |
- NPP_mutexattr_t a; |
- #endif |
- |
- #ifdef NOPMUTEX |
- NOP_mutexattr_t a; |
- #endif |
- |
- |
- KEY_EVT emerg; |
- |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- emerg.status = KEY_PRESSED; |
- keyb_hook(emerg,fine,FALSE); |
- |
- clear(); |
- |
- cprintf("Press Alt-x to end the demo..."); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,100000); |
- hard_task_def_wcet(m,ASTER_WCET); |
- hard_task_def_group(m,1); |
- hard_task_def_ctrl_jet(m); |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt,1); |
- nrt_task_def_ctrl_jet(m_nrt); |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_ctrl_jet(m_aper); |
- soft_task_def_aperiodic(m_aper); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,10000); |
- soft_task_def_met(m_soft,JET_WCET); |
- soft_task_def_group(m_soft,1); |
- soft_task_def_ctrl_jet(m_soft); |
- soft_task_def_aperiodic(m_soft); |
- |
- p1 = task_create("Aster",aster,&m,NULL); |
- if (p1 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <aster> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m,50000); |
- hard_task_def_wcet(m,CLOCK_WCET); |
- p2 = task_create("Clock",clock,&m,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <Clock> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- p3 = task_create("JetControl",jetcontrol,&m_aper,NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("test7.c(main): Could not create task <JetControl> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- p4 = task_create("MyDummyAper",(void *(*)(void*))mydummyaper,&m_aper,NULL); |
- if (p4 == -1) { |
- sys_shutdown_message("Could not create task <MyDummyAper> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- p5 = task_create("MyDummyNRT",(void *(*)(void*))mydummynrt,&m_nrt,NULL); |
- if (p5 == -1) { |
- sys_shutdown_message("Could not create task <MyDummyNRT> ..."); |
- sys_end(); |
- return 0; |
- } |
- |
- #ifdef PIMUTEX |
- PI_mutexattr_default(a); |
- #endif |
- |
- #ifdef PCMUTEX |
- PC_mutexattr_default(a); |
- #endif |
- |
- #ifdef NPPMUTEX |
- NPP_mutexattr_default(a); |
- #endif |
- |
- #ifdef NOPMUTEX |
- NOP_mutexattr_default(a); |
- #endif |
- |
- mutex_init(&m1, &a); |
- |
- group_activate(1); |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/cabs.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/cabs.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/cabs.c (nonexistent) |
@@ -1,290 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: cabs.c,v 1.7 2004-04-23 07:57:33 giacomo Exp $ |
- */ |
- |
-/*--------------------------------------------------------------*/ |
-/* TEST ON CABS */ |
-/*--------------------------------------------------------------*/ |
- |
-#include <kernel/kern.h> |
-#include <modules/cabs.h> |
-#include <string.h> |
- |
-#include <drivers/shark_fb26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-#define NCAB 4 /* max number of CABs */ |
-#define NCAR 26 /* generated characters */ |
- |
-#define YP 32 /* level of arrows */ |
-#define R 20 /* task radius */ |
-#define YY (YP+R+32) /* level of writing */ |
-#define DELTA (2*R+72) /* total channel hight */ |
-#define X1 120 /* start column for P1 */ |
-#define X2 360 /* start column for P2 */ |
- |
-#define XP1 (X1+64) /* X position of task 1 */ |
-#define XP2 (X2+64) /* X position of task 2 */ |
-#define XC (XP1+96) /* X position of CAB */ |
-#define L 52 /* CAB rectangle length */ |
- |
-void my_exit(KEY_EVT *k); |
-void draw_channel(int i); |
-void create_channel(int i); |
-void get_data(); |
- |
-TASK producer(void *arg); |
-TASK consumer(void *arg); |
- |
-char *cname[NCAB] = {"cab1", "cab2", "cab3", "cab4"}; |
-char *pname1[NCAB] = {"wr1", "wr2", "wr3", "wr4"}; |
-char *pname2[NCAB] = {"rd1", "rd2", "rd3", "rd4"}; |
- |
-CAB cid[NCAB]; /* CAB identifiers */ |
-PID p1[NCAB], p2[NCAB]; /* task identifiers */ |
- |
-/* Task Periods */ |
-TIME t1[NCAB] = {200000, 100000, 300000, 800000}; |
-TIME t2[NCAB] = {400000, 400000, 150000, 200000}; |
- |
-/* Task WCETS */ |
-TIME w1[NCAB] = {10000, 10000, 10000, 10000}; |
-TIME w2[NCAB] = {10000, 10000, 10000, 10000}; |
- |
-/****************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-/*--------------------------------------------------------------*/ |
-/* Main task */ |
-/*--------------------------------------------------------------*/ |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- char c = 0; /* character from keyboard */ |
- |
- grx_clear(BLACK); |
- |
- grx_text("Press a key [1-4]", 10, 16, rgb16(255,255,255), 0); |
- grx_text("to create a pair", 10, 24, rgb16(255,255,255), 0); |
- grx_text("ESC to exit demo", 10, 48, rgb16(255,255,255), 0); |
- |
- while (c != 27) { |
- c = keyb_getch(BLOCK); |
- if ((c >= '1') && (c <= '1'+NCAB-1)) |
- create_channel(c-'1'); |
- } |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
- |
-/*--------------------------------------------------------------*/ |
-/* write data in a cab */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK producer(void *arg) |
-{ |
-int i = (int)arg; |
-char c; /* message character */ |
-char *p; /* pointer to a cab buffer */ |
-char s[2]; /* string to display */ |
-int k = 0; |
-int x, y; |
-int col = rgb16(0,0,255); |
-int ybase = YY + i*DELTA; |
- |
- x = X1; |
- y = ybase; |
- s[1] = 0; |
- |
- k = 0; |
- while (1) { |
- c = 'A' + k; |
- p = cab_reserve(cid[i]); |
- *p = c; |
- cab_putmes(cid[i], p); |
- |
- s[0] = c; |
- k = (k + 1) % NCAR; |
- grx_text(s,x,y,col,0); |
- |
- x += 8; |
- if (x >= (X1 + NCAR*8)) { |
- x = X1; |
- y = y + 8; |
- if (y >= ybase+16) { |
- y = ybase; |
- } |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* read data from a cab */ |
-/*--------------------------------------------------------------*/ |
- |
-TASK consumer(void *arg) |
-{ |
-int i = (int)arg; |
-char *p; |
-char s[2]; |
-int x, y; |
-int col = 13; |
-int ybase = YY + i*DELTA; |
- |
- x = X2; |
- y = ybase; |
- s[1] = 0; |
- |
- while (1) { |
- p = cab_getmes(cid[i]); |
- s[0] = *p - 'A' + 'a'; |
- cab_unget(cid[i], p); |
- |
- grx_text(s,x,y,col,0); |
- x += 8; |
- |
- if (x >= (X2 + NCAR*8)) { |
- x = X2; |
- y = y + 8; |
- if (y >= ybase+16) { |
- y = ybase; |
- col = col % 15 + 1; |
- } |
- } |
- task_endcycle(); |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* create the two tasks and a channel */ |
-/*--------------------------------------------------------------*/ |
- |
-void create_channel(int i) |
-{ |
- HARD_TASK_MODEL m; |
- |
- draw_channel(i); |
- cid[i] = cab_create(cname[i], 1, 2); |
- |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, w1[i]); |
- hard_task_def_mit (m, t1[i]); |
- hard_task_def_usemath (m); |
- p1[i] = task_create(pname1[i], producer, &m, NULL); |
- if (p1[i] == NIL) { |
- sys_shutdown_message("Could not create task <producer>"); |
- sys_end(); |
- return; |
- } |
- task_activate(p1[i]); |
- |
- hard_task_default_model(m); |
- hard_task_def_ctrl_jet (m); |
- hard_task_def_arg (m, (void *)i); |
- hard_task_def_wcet (m, w2[i]); |
- hard_task_def_mit (m, t2[i]); |
- hard_task_def_usemath (m); |
- p2[i] = task_create(pname2[i], consumer, &m, NULL); |
- if (p2[i] == NIL) { |
- sys_shutdown_message("Could not create task <consumer>"); |
- sys_end(); |
- return; |
- } |
- task_activate(p2[i]); |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* Disegna i processi e il canale di comunicazione */ |
-/*--------------------------------------------------------------*/ |
- |
-void draw_channel(int i) |
-{ |
-char buffer[32]; /* buffer per sprintf */ |
-int yc = YP + i*DELTA; /* altezza del canale */ |
- |
- grx_circle(XP1,yc,R,rgb16(255,0,0)); |
- grx_text("P1",XP1-8,yc-4,rgb16(255,255,255),0); |
- |
- grx_circle(XP2,yc,R,rgb16(255,0,0)); |
- grx_text("P2",XP2-8,yc-4,rgb16(255,255,255),0); |
- |
- grx_rect(XC,yc-R,XC+L,yc+R,rgb16(255,255,255)); |
- grx_text("CAB",XC+16,yc-4,rgb16(255,255,255),0); |
- |
- grx_line(XP1+R,yc,XC,yc,rgb16(255,255,255)); |
- grx_line(XC+L,yc,XP2-R,yc,rgb16(255,255,255)); |
- |
- grx_text("T1 = ms",X1+40,yc+R+16,rgb16(255,255,255),0); |
- sprintf(buffer,"%ld", t1[i]); |
- grx_text(buffer,X1+88,yc+R+16,rgb16(255,255,255),0); |
- |
- grx_text("T2 = ms",X2+40,yc+R+16,rgb16(255,255,255),0); |
- sprintf(buffer,"%ld", t2[i]); |
- grx_text(buffer,X2+88,yc+R+16,rgb16(255,255,255),0); |
-} |
Index: tags/rel_1_4_rc1/base/iaster1.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster1.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster1.c (nonexistent) |
@@ -1,99 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster1.c,v 1.2 2003-04-15 10:21:22 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2003-04-15 10:21:22 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models (into () the mandatory fields): |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/srpdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/srpdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/srpdemo.c (nonexistent) |
@@ -1,234 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: srpdemo.c,v 1.3 2004-04-17 11:36:15 giacomo Exp $ |
- |
- This test verify the correctness of the SRP module. |
- |
- There are 3 taks, Jh, Jm, Jl that uses 3 mutexes m1, m2, m3 |
- |
- the main task (NRT) creates the three tasks. |
- |
- Jh with preemption level 3 |
- starts at t=1.5 sec and lock m3, lock m1, unlock m1, unlock m3 |
- |
- Jm with preemption level 2 |
- starts at t=0.5 sec and lock m3, lock m2, unlock m2, unlock m3 |
- then lock and unlock m1 |
- |
- Jl with preemption level 1 |
- it starts and locks m2 |
- at t=1 sec it locks m1 |
- at t=1.5 sec it unlocks m1 |
- then it unlocks m2, and finally it locks and unlocks m3 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 210 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/srp.h" |
- |
-mutex_t m1,m2,m3; |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK Jlobby() |
-{ |
- cprintf("(*) JLobby!!!\n"); |
- return 0; |
-} |
- |
-TASK Jh() |
-{ |
- PID l; |
- HARD_TASK_MODEL m; |
- SRP_RES_MODEL r; |
- |
- cprintf("JH: creating Jy before locking m3\n"); |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,30000); |
- hard_task_def_wcet(m,1000); |
- SRP_res_default_model(r,4); |
- l = task_create("Jlobby",Jlobby,&m,&r); |
- task_activate(l); |
- |
- mutex_lock(&m3); |
- cprintf("JH: locked m3, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JH: locked m1, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JH: unlocked m1, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JH: unlocked m3, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK Jm() |
-{ |
- cprintf("JM: before locking m3\n"); |
- mutex_lock(&m3); |
- cprintf("JM: locked m3, locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("JM: locked m2, unlocking m2\n"); |
- mutex_unlock(&m2); |
- cprintf("JM: unlocked m2, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JM: unlocked m3, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JM: locked m1, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JM: unlocked m1, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK Jl() |
-{ |
- cprintf("JL: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("JL: locked m2, waiting to t=1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("JL: t = 1 sec reached, locking m1\n"); |
- mutex_lock(&m1); |
- cprintf("JL: locked m1, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("JL: t = 2 sec reached, unlocking m1\n"); |
- mutex_unlock(&m1); |
- cprintf("JL: unlocked m1, unlocking m2\n"); |
- |
- mutex_unlock(&m2); |
- |
- cprintf("JL: unlocked m2, locking m3\n"); |
- mutex_lock(&m3); |
- cprintf("JL: locked m3, unlocking m3\n"); |
- mutex_unlock(&m3); |
- cprintf("JL: unlocked m3, end task\n"); |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- SRP_mutexattr_t a; |
- SRP_RES_MODEL r; |
- |
- PI_mutexattr_t a2; |
- |
- clear(); |
- |
- cprintf("Stack resource Policy demo. It ends after 60 sec\n"); |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a2); |
- SRP_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- mutex_init(&m2,&a); |
- mutex_init(&m3,&a); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 1000000); |
- hard_task_def_wcet(m, 80000); |
- SRP_res_default_model(r, 3); |
- p0 = task_createn("JH", Jh, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create JH task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 2100000); |
- hard_task_def_wcet(m, 80000); |
- SRP_res_default_model(r, 2); |
- p1 = task_createn("JM", Jm, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), |
- SRP_usemutex(&m2), NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create JM task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 10000000); |
- hard_task_def_wcet(m, 3000000); |
- SRP_res_default_model(r, 1); |
- p2 = task_createn("JL", Jl, (TASK_MODEL *)&m, &r, SRP_usemutex(&m3), SRP_usemutex(&m1), |
- SRP_usemutex(&m2), NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create JL task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p1); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p0); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 60); |
- |
- sys_end(); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/imdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/imdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/imdemo.c (nonexistent) |
@@ -1,102 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: imdemo.c,v 1.3 2004-04-19 14:48:05 giacomo Exp $ |
-**/ |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
- |
-} |
- |
Index: tags/rel_1_4_rc1/base/iaster3.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster3.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster3.c (nonexistent) |
@@ -1,110 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster3.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.2 $ |
- Last update: $Date: 2004-04-17 11:36:13 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a TBS (Total Bandwidth Server) level 0.1 Us |
- a TBS (Total Bandwidth Server) level 0.3 Us |
- a Dummy level |
- |
- The TBS bandwidth is TBS_NUM/TBS_DEN |
- |
- |
- It can accept these task models (into () the mandatory fields): |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (wcet, periodicity=APERIODIC) at level 2,3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/tbs.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1200 |
- |
-#define RRTICK 5000 |
-#define TBS_NUM 1 |
-#define TBS_DEN 10 |
- |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM, TBS_DEN); |
- TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM*3, TBS_DEN); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/ego.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/ego.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/ego.c (nonexistent) |
@@ -1,203 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ego.c,v 1.6 2004-04-19 14:48:05 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.6 $ |
- Last update: $Date: 2004-04-19 14:48:05 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/****************************************************************/ |
-/* PERIODIC PROCESS TEST */ |
-/****************************************************************/ |
- |
-#include <kernel/kern.h> |
- |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
-#define X0 10 |
- |
-/* task periods */ |
-#define PERIOD_T1 100000 |
-#define PERIOD_T2 200000 |
-#define PERIOD_T3 300000 |
- |
-/* X position of the text printed by each task */ |
-int y[3] = {100, 180, 260}; |
- |
-/* text printed by each task */ |
-char talk[3][50] = { "I am ego1 and I print a character every 100 ms", |
- "I am ego2 and I print a character every 200 ms", |
- "I am ego3 and I print a character every 300 ms"}; |
- |
-/***************************************************************/ |
- |
-TASK ego(void *arg) |
-{ |
-int i = (int)arg; |
-int leng; |
-char s[2]; |
-int x; |
-int j = 0; |
- |
- /* compute the length of the string to print */ |
- leng = 0; |
- while (talk[i][leng] != 0) leng++; |
- |
- x = X0; |
- s[1] = 0; |
- task_endcycle(); |
- |
- while (1) { |
- s[0] = talk[i][j]; |
- grx_text(s,x,y[i],rgb16(255,255,255),0); |
- x += 8; |
- if (++j == leng) { |
- j = 0; |
- x = X0; |
- y[i] += 8; |
- if (y[i]>340) y[i]=100; |
- } |
- task_endcycle(); |
- } |
-} |
- |
- |
-/****************************************************************/ |
- |
-/* This function is called when Alt-X is pressed. |
-*/ |
-void my_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-/******************************************************************/ |
- |
-/* This function is called when the system exit correctly after Alt-X. |
- It exits from the graphic mode and then it prints a small greeting. |
- Note that: |
- - The function calls grx_exit, so it must be registered using |
- RUNLEVEL_BEFORE_EXIT (RUNLEVEL_AFTER_EXIT does not work because |
- at that point the kernel is already returned in real mode!!!) |
- - When an exception is raised, the exception handler is called. |
- Since the exception handler already exits from the graphic mode, |
- this funcion has not to be called. For this reason: |
- . we registered byebye using the flag NO_AT_ABORT |
- . the exception handler exits using sys_abort; in that way byebye is |
- NOT called |
-*/ |
- |
-/****************************** MAIN ******************************/ |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid1, pid2, pid3; |
- KEY_EVT emerg; |
- HARD_TASK_MODEL m1, m2, m3; |
- |
- /* set the keyboard handler to exit correctly */ |
- emerg.ascii = 'x'; |
- emerg.scan = KEY_X; |
- emerg.flag = ALTL_BIT; |
- emerg.status = KEY_PRESSED; |
- keyb_hook(emerg,my_end,FALSE); |
- |
- /* a small banner */ |
- grx_text("EGO Test",8,8,rgb16(255,255,255),0); |
- grx_text("Press Alt-X to exit",8,16,rgb16(255,255,255),0); |
- |
- /* ego1 creation */ |
- hard_task_default_model(m1); |
- hard_task_def_ctrl_jet (m1); |
- hard_task_def_arg (m1, (void *)0); |
- hard_task_def_wcet (m1, 5000); |
- hard_task_def_mit (m1, PERIOD_T1); |
- hard_task_def_group (m1,1); |
- pid1 = task_create("ego1", ego, &m1, NULL); |
- if (pid1 == NIL) { |
- sys_shutdown_message("Could not create task <ego1>"); |
- sys_end(); |
- return 0; |
- } |
- |
- /* ego2 creation */ |
- hard_task_default_model(m2); |
- hard_task_def_ctrl_jet (m2); |
- hard_task_def_arg (m2, (void *)1); |
- hard_task_def_wcet (m2, 5000); |
- hard_task_def_mit (m2, PERIOD_T2); |
- hard_task_def_group (m2,1); |
- pid2 = task_create("ego2", ego, &m2, NULL); |
- if (pid2 == NIL) { |
- sys_shutdown_message("Could not create task <ego2>"); |
- sys_end(); |
- return 0; |
- } |
- |
- /* ego3 creation */ |
- hard_task_default_model(m3); |
- hard_task_def_ctrl_jet (m3); |
- hard_task_def_arg (m3, (void *)2); |
- hard_task_def_wcet (m3, 5000); |
- hard_task_def_mit (m3, PERIOD_T3); |
- hard_task_def_group (m3,1); |
- pid3 = task_create("ego3", ego, &m3, NULL); |
- if (pid3 == NIL) { |
- sys_shutdown_message("Could not create task <ego3>"); |
- sys_end(); |
- return 0; |
- } |
- |
- /* and finally we activate the three threads... */ |
- group_activate(1); |
- |
- /* |
- now the task main ends, but the system does not shutdown because |
- there are the three task ego1, ego2, and ego3 running. |
- |
- The demo will finish if a Alt-X key is pressed. |
- */ |
- |
- return 0; |
-} |
- |
-/****************************************************************/ |
Index: tags/rel_1_4_rc1/base/iaster4.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster4.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster4.c (nonexistent) |
@@ -1,182 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/rr.h" |
-#include "modules/tbs.h" |
-#include "modules/cbs.h" |
-#include "modules/rrsoft.h" |
-#include "modules/dummy.h" |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-#define RRTICK 5000 |
-#define TBS_NUM 1 |
-#define TBS_DEN 10 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- TBS_register_level(TBS_ENABLE_ALL, 1, TBS_NUM, TBS_DEN); |
- TBS_register_level(TBS_ENABLE_ALL, 1, TBS_NUM*3, TBS_DEN); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/base/preempt.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/preempt.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/preempt.c (nonexistent) |
@@ -1,149 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: preempt.c,v 1.3 2004-04-19 14:48:05 giacomo Exp $ |
- |
- CBS test with preemption disabling |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-void *periodic(void *arg) |
-{ |
- int i; |
- int y = (int)arg; |
- |
- for (i = 19; i < 60; i++) { |
- puts_xy(i,y,7,"*"); |
- |
- task_endcycle(); |
- } |
- |
- cprintf("Periodic: Task %d end.\n", exec_shadow); |
- |
- return 0; |
-} |
- |
-void *blocker(void *arg) |
-{ |
- struct timespec t; |
- |
- task_nopreempt(); |
- cprintf("Blocker: Task nopreempt\n"); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 5); |
- |
- cprintf("Blocker: Task preempt\n"); |
- task_preempt(); |
- |
- cprintf("Blocker: end\n"); |
- |
- return 0; |
-} |
- |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- NRT_TASK_MODEL m; |
- SOFT_TASK_MODEL m_aper; |
- PID p; |
- |
- clear(); |
- cprintf("Preemption Test.\n"); |
- cprintf("Start time: two periodic tasks and a blocker are created and activated.\n"); |
- cprintf("2 seconds : blocker calls task_nopreempt.\n"); |
- cprintf("5 seconds : task_preempt is called.\n"); |
- cprintf(" The blocked task exec its pending activations.\n"); |
- cprintf("10 seconds: the test stops.\n"); |
- puts_xy(1,20,7,"save task:"); |
- puts_xy(1,21,7,"skip task:"); |
- |
- nrt_task_default_model(m); |
- |
- soft_task_default_model(m_aper); |
- soft_task_def_met(m_aper,10000); |
- soft_task_def_period(m_aper,200000); |
- soft_task_def_group(m_aper,1); |
- soft_task_def_arg(m_aper, (void *)20); |
- soft_task_def_periodic(m_aper); |
- |
- p = task_create("save", periodic, &m_aper, NULL); |
- if (p == NIL) |
- { |
- sys_shutdown_message("Can't create save task...\n"); |
- sys_end(); |
- } |
- |
- soft_task_def_skip_arrivals(m_aper); |
- soft_task_def_arg(m_aper, (void *)21); |
- |
- p = task_create("skip", periodic, &m_aper, NULL); |
- if (p == NIL) |
- { |
- sys_shutdown_message("Can't create skip task...\n"); |
- sys_end(); |
- } |
- |
- p = task_create("blocker", blocker, &m, NULL); |
- if (p == NIL) |
- { |
- sys_shutdown_message("Can't create blocker task...\n"); |
- sys_end(); |
- } |
- |
- cprintf("main : save & skip tasks activated.\n"); |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 2); |
- |
- cprintf("main : blocker activated.\n"); |
- task_activate(p); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- cprintf("main : End!!!\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/ihello.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/ihello.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/ihello.c (nonexistent) |
@@ -1,95 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: ihello.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1 $ |
- Last update: $Date: 2002-10-28 08:13:37 $ |
- ------------ |
- |
- The simplest initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register the following levels: |
- |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- NRT_TASK_MODEL at level 0 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 300 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/iaster6.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster6.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster6.c (nonexistent) |
@@ -1,226 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster6.c,v 1.4 2004-05-24 17:20:44 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2004-05-24 17:20:44 $ |
- ------------ |
- |
- System initialization file |
- |
- h3pips.c |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a RR (Round Robin) level |
- a CBS (Costant Bandwidth Server) level |
- a PS (Polling Server) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- NRT_TASK_MODEL at level 1 |
- SOFT_TASK_MODEL (met, period) at level 2 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
- |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/ps.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,1,500,100000); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
- |
Index: tags/rel_1_4_rc1/base/iaster7.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster7.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster7.c (nonexistent) |
@@ -1,214 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster7.c,v 1.4 2004-05-24 17:20:45 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2004-05-24 17:20:45 $ |
- ------------ |
- |
- System initialization file |
- |
- The tick is set to TICK ms. |
- |
- This file contains the 2 functions needed to initialize the system. |
- |
- These functions register a set of scheduling modules, in a fixed or |
- dynamic priority way... |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 1 |
- NRT_TASK_MODEL at level 2 |
- SOFT_TASK_MODEL (periodicity=APERIODIC, wcet (only if TBS) ) at level 3,4 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/tbs.h" |
- |
-#include "modules/rm.h" |
-#include "modules/rr.h" |
-#include "modules/ps.h" |
- |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- RM_register_level(RM_ENABLE_ALL); |
- PS_register_level(PS_ENABLE_ALL_RM,1,1000,100000); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- PS_register_level(4,1,10000,100000); |
- PS_register_level(4,1,30000,100000); |
- |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
- |
- |
- |
Index: tags/rel_1_4_rc1/base/aster.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/aster.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/aster.c (nonexistent) |
@@ -1,383 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai, Gerardo Lamastra and Giuseppe Lipari |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: aster.c,v 1.4 2004-04-18 19:46:29 giacomo Exp $ |
- |
- Author: Gerardo Lamastra |
- Giuseppe Lipari |
- Date: 1/10/96 |
- |
- File: Aster.C |
- Revision: 1.6 |
- |
-*/ |
- |
-/* |
- Well, this is only a stupid demo which intend to show many |
- HARTIK+ capabilities; the application is structured in the followig |
- way: there is an ASTER task wich randomly creates some ASTEROID tasks |
- which are displayed into the first window; each task is HARD/PERIODIC |
- and auto-kills itself when it reaches the window end! |
- An other couple of tasks, TITLE & PUT give an example of port |
- communication facility; the server task creates the port, the client |
- task connect to it and uses the server to accomplish some stuff. |
- Port can be declared READ/WRITE and can model ONE-TO-ONE communication |
- or MANY-TO-ONE communication. |
- Finally a second couple of tasks realizes a communiation through CABs; |
- each time a key is pressed, the ascii code is posted into the CAB by the |
- CCC task while the second task, WRITE, displays it on the screen and |
- perform other silly actions. |
- Finally a CLOCK task is implemented to test system clock. |
- Please note that usually the HARTIK+ application is made up of a task |
- group which interacts among them, while the main() function, which |
- became a task itself when the kernel is activated, is suspended until |
- the system is ready to terminate; the MAIN task can also be used to make |
- other background activities, but it should not be killed; when the |
- application terminates, the control is passed to MAIN which kills |
- everybody, shut down the system and can handle other operations using |
- the services available with the previou operating system (I.E. the DOS). |
- If you need to manage sudden abort/exception you should install your own |
- exception handler and raise it through the exc_raise() primitive to |
- make the system abort safely! |
- Remember that the exit functions posted through sys_atexit() will be |
- executed in both cases, to allow clean system shutdown. |
-*/ |
- |
-#include <kernel/kern.h> |
-#include <modules/sem.h> |
-#include <modules/hartport.h> |
-#include <modules/cabs.h> |
-#include <string.h> |
- |
-#include <drivers/shark_keyb26.h> |
- |
-//#define __VPAGING__ |
- |
-#include <drivers/crtwin.h> |
- |
-int num_aster = 0; |
-#define ASTER_LIM 67 |
- |
-CAB cc; |
-BYTE esc = FALSE; |
- |
-TASK asteroide(void) |
-{ |
- int i = 1; |
- int y = rand() % 7 + 1; |
- while (i < ASTER_LIM) { |
- puts_xy(i,y,WHITE,"*"); |
- task_endcycle(); |
- |
- puts_xy(i,y,WHITE," "); |
- i++; |
- } |
- num_aster--; |
- return 0; |
-} |
- |
-DWORD taskCreated = 0; |
- |
-TASK aster(void) |
-{ |
- PID p; |
- SOFT_TASK_MODEL m_soft; |
- int r; |
- WIN w; |
- |
- win_init(&w,0,0,ASTER_LIM,8); |
- win_frame(&w,BLACK,WHITE,"Asteroids",2); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_met(m_soft,2000); |
- soft_task_def_ctrl_jet(m_soft); |
- |
- srand(7); |
- while (1) { |
- if (num_aster < 5) { |
- r = (rand() % 50) - 25; |
- soft_task_def_arg(m_soft,(void *)((rand() % 7)+1)); |
- soft_task_def_period(m_soft,(50 + r)*1000); |
- p = task_create("aaa",asteroide,(TASK_MODEL *)&m_soft,NULL); |
- taskCreated++; |
- task_activate(p); |
- num_aster++; |
- } |
- |
- task_endcycle(); |
- } |
-} |
- |
-TASK clock() |
-{ |
- WIN w; |
- int s = 0, m = 0; |
- |
- win_init(&w,68,0,11,2); |
- win_frame(&w,BLACK,WHITE,"Clk",1); |
- |
- while(1) { |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- |
- if (++s > 59) { |
- s = 0; |
- m++; |
- } |
- printf_xy(70,1,WHITE,"%2d : %2d",m,s); |
- task_endcycle(); |
- } |
-} |
- |
-TASK title() |
-{ |
- PORT t; |
- WIN w; |
- int i,pos = 77; |
- char msg[85],tmp[85],ss[2]; |
- BYTE c; |
- |
- win_init(&w,0,9,79,2); |
- win_frame(&w,BLACK,WHITE,"Title",2); |
- |
- for (i=0; i < 77; i++) msg[i] = ' '; |
- msg[77] = 0; |
- |
- t = port_connect("title",1,STREAM,READ); |
- |
- while (1) { |
- port_receive(t,&c,BLOCK); |
- ss[0] = c; |
- ss[1] = 0; |
- strcat(msg,ss); |
- puts_xy(1,10,WHITE,msg); |
- pos++; |
- if (pos > 77) { |
- strcpy(tmp,&(msg[1])); |
- tmp[pos-1] = 0; |
- pos -= 1; |
- strcpy(msg,tmp); |
- } |
- task_endcycle(); |
- } |
-} |
- |
-#define STR "..................... S.Ha.R.K. ....................."\ |
- " Guarantees hard tasks "\ |
- " Includes soft periodic tasks "\ |
- "TB server for decrementing the aperiodic response time "\ |
- "SRP for both hard & soft aperiodic tasks "\ |
- "Portability toward other compilers/system "\ |
- " "\ |
- "Programmers : Gerardo Lamastra (lamastra@sssup2.sssup.it) "\ |
- " Giuseppe Lipari (lipari@sssup2.sssup.it) "\ |
- "Research coordinator: Giorgio Buttazzo (giorgio@sssup1.sssup.it)"\ |
- " "\ |
- " "\ |
- " " |
- |
-static char GreetMsg[1600]; |
- |
-TASK put(void) |
-{ |
- PORT p; |
- |
- strcpy(GreetMsg,STR); |
- |
- p = port_create("title",strlen(GreetMsg),1,STREAM,WRITE); |
- while(1) { |
- port_send(p,GreetMsg,BLOCK); |
- task_endcycle(); |
- } |
-} |
- |
-TASK ccc(void) |
-{ |
- WIN w; |
- char *m; |
- |
- win_init(&w,68,3,10,3); |
- win_frame(&w,BLACK,WHITE,"CCC",2); |
- puts_xy(70,4,WHITE,"Cab"); |
- |
- while(1) { |
- m = cab_getmes(cc); |
- puts_xy(72,5,WHITE,m); |
- cab_unget(cc,m); |
- task_endcycle(); |
- } |
-} |
- |
- |
-TASK write_keyb() |
-{ |
- BYTE c; |
- char *msg; |
- |
- while (1) { |
- c = keyb_getchar(); |
- if (c == ESC) { |
- esc = TRUE; |
- task_endcycle(); |
- } |
- else { |
-#ifdef __VPAGING__ |
- if (c == 's') { |
- if (get_visual_page() == 0) set_visual_page(1); |
- else if (get_visual_page() == 1) set_visual_page(0); |
- } |
-#endif |
- msg = cab_reserve(cc); |
- msg[0] = c; |
- msg[1] = 0; |
- cab_putmes(cc,msg); |
- } |
- } |
-} |
- |
-#define DELTA 200000.0 |
-double carico(double rif,BYTE init) |
-{ |
- double i; |
- DWORD t1 = 0,t2 = 1000; |
- double u; |
- |
- i = 0.0; |
- do { |
- i += 1; |
- } while (i <= DELTA); |
- |
- u = i / ((double) (t2 - t1)); |
- |
- if (init) return u; |
- else return (1.0 - u/rif); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID p1,p2,p3,p4,p5,p6; |
- |
- HARD_TASK_MODEL m_per; |
- SOFT_TASK_MODEL m_soft; |
- NRT_TASK_MODEL m_nrt; |
- |
- struct timespec t; |
- |
-#ifdef __VPAGING__ |
- set_active_page(1); |
- set_visual_page(1); |
-#endif |
- |
- CRSR_OFF(); |
- clear(); |
- puts_xy(0,20,WHITE,"Press ESC to exit demo."); |
- cc = cab_create("Cab",2,2); |
- |
- soft_task_default_model(m_soft); |
- soft_task_def_period(m_soft,500000); |
- soft_task_def_met(m_soft,1000); |
- soft_task_def_group(m_soft, 1); |
- p1 = task_create("Aster",aster,&m_soft,NULL); |
- if (p1 == -1) { |
- perror("Aster.C(main): Could not create task <aster>"); |
- sys_abort(-1); |
- } |
- |
- hard_task_default_model(m_per); |
- hard_task_def_mit(m_per,500000); |
- hard_task_def_wcet(m_per,1000); |
- hard_task_def_group(m_per, 1); |
- p2 = task_create("Clock",clock,&m_per,NULL); |
- if (p2 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <Clock>"); |
- sys_end(); |
- return 0; |
- } |
- |
- soft_task_def_period(m_soft, 50000); |
- p3 = task_create("Title",title,&m_soft, NULL); |
- if (p3 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <Title>"); |
- sys_end(); |
- return 0; |
- } |
- |
- soft_task_def_period(m_soft, 1000000); |
- p4 = task_create("Put",put,&m_soft, NULL); |
- if (p4 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <Put>"); |
- sys_end(); |
- return 0; |
- } |
- |
- nrt_task_default_model(m_nrt); |
- nrt_task_def_group(m_nrt, 1); |
- p5 = task_create("Write",write_keyb,&m_nrt,NULL); |
- if (p5 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <Write>"); |
- sys_end(); |
- return 0; |
- } |
- |
- hard_task_def_mit(m_per, 50000); |
- p6 = task_create("CabTask",ccc,&m_per,NULL); |
- if (p6 == -1) { |
- sys_shutdown_message("Aster.C(main): Could not create task <CabTask>\n"); |
- sys_end(); |
- return 0; |
- } |
- |
- group_activate(1); |
- |
- while (!esc) { |
- sys_gettime(&t); |
- printf_xy(0,21,WHITE,"Clock : %-9ds %-9dns",(int)t.tv_sec, (int)t.tv_nsec); |
- } |
- |
- group_kill(1); |
- clear(); |
- CRSR_STD(); |
-#ifdef __VPAGING__ |
- set_active_page(0); |
- set_visual_page(0); |
-#endif |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
- |
Index: tags/rel_1_4_rc1/base/iaster8.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/iaster8.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/iaster8.c (nonexistent) |
@@ -1,228 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: iaster8.c,v 1.4 2004-05-24 17:20:45 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.4 $ |
- Last update: $Date: 2004-05-24 17:20:45 $ |
- ------------ |
- |
- System initialization file |
- |
- h3piss.c |
- |
- These functions register the following levels: |
- |
- an EDF (Earliest Deadline First) level |
- a CBS (Costant Bandwidth Server) level |
- a SS (Sporadic Server) level |
- a RR (Round Robin) level |
- a Dummy level |
- |
- It can accept these task models: |
- |
- HARD_TASK_MODEL (wcet+mit) at level 0 |
- SOFT_TASK_MODEL (met, period) at level 1 |
- SOFT_TASK_MODEL (periodicity=APERIODIC) at level 2 |
- NRT_TASK_MODEL at level 3 |
- |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
- |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/rm.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/ss.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-/*+ system tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- SS_register_level(SS_ENABLE_GUARANTEE_EDF,1,5000,20000); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- PC_register_module(); |
- PI_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
- |
- |
- |
Index: tags/rel_1_4_rc1/base/pcidemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/pcidemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/pcidemo.c (nonexistent) |
@@ -1,45 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "unistd.h" |
- |
-int main (int argc, char *argv[]) |
-{ |
- |
- cprintf("Init Done...\n"); |
- |
- sleep(5); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/base/sig.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/sig.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/sig.c (nonexistent) |
@@ -1,168 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: sig.c,v 1.3 2003-01-07 17:10:15 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.3 $ |
- Last update: $Date: 2003-01-07 17:10:15 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/* |
- Test Number 5: |
- |
- this test is a simple main() function with one other task |
- |
- This test can be useful to test functions like: |
- |
- sys_gettime |
- sigemptyset |
- sigaddset |
- hartik_deliver_pending_signals |
- sys_end |
- task_sigmask |
- sigaction |
- sigqueue |
- task_signal |
-*/ |
- |
-#include "kernel/kern.h" |
- |
- |
-TASK goofy(void *arg) |
-{ |
- struct timespec t; |
- |
- cprintf("Goofy: waiting 2 secs...\n"); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 2); // wait until 2 sec |
- |
- cprintf("Goofy: ok, I'm ready :-)\n"); |
- |
- return 0; |
-} |
- |
-void catchit_RT(int signo, siginfo_t *info, void *extra) |
-{ |
- cprintf("RT signal: Current Running Task = %d signo=%d code=%d value=%d from pid=%d\n", |
- exec_shadow, |
- info->si_signo, info->si_code, |
- info->si_value.sival_int, info->si_task); |
-} |
- |
-void catchit(int signo) |
-{ |
- cprintf("RT signal: Current Running Task = %d signo=%d\n", |
- exec_shadow, signo); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- NRT_TASK_MODEL m; |
- PID p2; |
- |
- sigset_t newmask; |
- sigset_t oldmask; |
- struct sigaction action; |
- union sigval sval; |
- |
- clear(); |
- |
- /* Set the signal action */ |
- action.sa_flags = SA_SIGINFO; |
- action.sa_sigaction = catchit_RT; |
- action.sa_handler = 0; |
- action.sa_mask = 0; |
- |
- if (sigaction(SIGUSR1, &action, NULL) == -1) { |
- perror("Error using sigaction."); |
- return -1; |
- } |
- |
- action.sa_flags = 0; |
- action.sa_handler = (void (*)(int))catchit; |
- |
- if (sigaction(SIGILL, &action, NULL) == -1) { |
- perror("Error using sigaction."); |
- return -1; |
- } |
- |
- /* create another task */ |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- p2 = task_create("goofy", goofy, &m, NULL); |
- if (p2 == NIL) |
- { |
- cprintf("Can't create goofy task...\n"); |
- return 1; |
- } |
- |
- group_activate(1); |
- |
- /* block the signal for the main task */ |
- sigemptyset(&newmask); |
- sigaddset(&newmask,SIGUSR1); |
- task_sigmask(SIG_BLOCK, &newmask, &oldmask); // pthread_sigmask |
- |
- cprintf("main: Sending 2 signals ...\n"); |
- |
- sval.sival_int = 123; |
- sigqueue(0,SIGUSR1,sval); |
- sval.sival_int = 999; |
- sigqueue(0,SIGUSR1,sval); |
- |
- cprintf("main: Now sending a signal to myself," |
- " then wait until 4 secs...\n"); |
- |
- task_signal(0 /* main */, SIGILL); // pthread_kill |
- |
- NULL_TIMESPEC(&t); |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 4); // wait until 4 s |
- |
- cprintf("main: ending...\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/semdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/semdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/semdemo.c (nonexistent) |
@@ -1,105 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: semdemo.c,v 1.2 2004-04-17 11:36:15 giacomo Exp $ |
- |
- This is a really simple semaphore demo. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-#include "semaphore.h" |
- |
-sem_t s; |
- |
-void *goofy(void *a) |
-{ |
- struct timespec t; |
- char *n = proc_table[exec_shadow].name; |
- |
- cprintf("Task %s: Locking semaphore...\n", n); |
- |
- sem_wait(&s); |
- cprintf("Task %s: Semaphore locked...\n", n); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < (int)a); |
- |
- cprintf("Task %s: Unlocking semaphore...\n", n); |
- |
- sem_post(&s); |
- |
- cprintf("Task %s: Semaphore unlocked...\n", n); |
- |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- PID p2,p3; |
- |
- struct timespec t; |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- nrt_task_def_arg(m,(void *)1); |
- p2 = task_create("goofy1", goofy, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create goofy1 task...\n"); return 1; } |
- |
- nrt_task_def_arg(m,(void *)2); |
- p3 = task_create("goofy2", goofy, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create goofy2 task...\n"); return 1; } |
- |
- cprintf("Initializing semaphore...\n"); |
- |
- sem_init(&s,0,1); |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/time.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/time.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/time.c (nonexistent) |
@@ -1,69 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: time.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- * |
- * Timer correctness test |
- */ |
- |
-#include "kernel/kern.h" |
- |
-#define NT 10 |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t[NT]; |
- int i; |
- |
- cprintf("Timer correctness test (1 second).\n"); |
- |
- for (i=0; i<NT; i++) NULL_TIMESPEC(&t[i]); |
- |
- do { |
- for (i=0; i<NT-1; i++) t[i+1] = t[i]; |
- |
- sys_gettime(&t[0]); |
- |
- if (TIMESPEC_A_LT_B(&t[0],&t[1])) { |
- for (i=0; i<NT; i++) |
- cprintf("%d %ld\n",i, t[i].tv_nsec); |
- sys_end(); |
- } |
- } while (t[0].tv_sec < 1); |
- |
- return 0; |
-} |
- |
Index: tags/rel_1_4_rc1/base/intsem.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/intsem.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/intsem.c (nonexistent) |
@@ -1,109 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: intsem.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $ |
- |
- this test is a simple main() function with one other task. |
- |
- This test verify the correctness of the internal_sem functions. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-#include <kernel/int_sem.h> |
- |
-internal_sem_t s; |
- |
-TASK pippo(void *a) |
-{ |
- int i=0; |
- struct timespec t; |
- |
- do { |
- sys_gettime(&t); |
- |
- if (i==0 && t.tv_sec == (int)a) { |
- i = 1; |
- cprintf("before internal_sem_wait %d\n",(int)a); |
- internal_sem_wait(&s); |
- cprintf("after internal_sem_wait %d\n",(int)a); |
- } |
- |
- if (i==1 && t.tv_sec == 2+(int)a) { |
- i = 2; |
- cprintf("before internal_sem_post %d\n",(int)a); |
- internal_sem_post(&s); |
- cprintf("after internal_sem_post %d\n",(int)a); |
- return 0; |
- } |
- |
- |
- } while (1); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- NRT_TASK_MODEL m; |
- PID p2,p3; |
- |
- struct timespec t; |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- |
- nrt_task_def_arg(m,(void *)1); |
- p2 = task_create("pippo1", pippo, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create pippo1 task...\n"); return 1; } |
- |
- nrt_task_def_arg(m,(void *)2); |
- p3 = task_create("pippo2", pippo, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create pippo2 task...\n"); return 1; } |
- |
- internal_sem_init(&s,1); |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/mdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/mdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/mdemo.c (nonexistent) |
@@ -1,189 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: mdemo.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $ |
- |
- This test verify the correctness of the NOP module. It works with the |
- PI, PC, SRP module, too. |
- |
- The test uses one mutex |
- |
- the main task (NRT) creates three tasks. |
- |
- J1 with PC priority 0 |
- starts at t=0.5 sec and lock m0 |
- |
- J2 with PC priority 1 |
- starts at t=1 sec and doesn't lock any mutex |
- |
- J3 with PC priority 2 |
- it starts and locks m0 |
- at t=2 sec it unlocks m1 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 188 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
-#include "modules/srp.h" |
- |
-mutex_t m0; |
- |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J1: locked m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J1: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
- cprintf("J2: waiting t=1.5 sec\n"); |
- |
- while (sys_gettime(NULL) < 1500000); |
- |
- cprintf("J2: end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j3() |
-{ |
- cprintf("J3: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J3: locked m0, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("J3: t = 1 sec reached, unlocking m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- PC_mutexattr_t a; |
- PI_mutexattr_t a2; |
- NOP_mutexattr_t a3; |
- SRP_mutexattr_t a4; |
- NPP_mutexattr_t a5; |
- |
- PC_RES_MODEL r; |
- SRP_RES_MODEL srp; |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PC_mutexattr_default(a,0); |
- PI_mutexattr_default(a2); |
- NOP_mutexattr_default(a3); |
- SRP_mutexattr_default(a4); |
- NPP_mutexattr_default(a5); |
- mutex_init(&m0,&a4); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_wcet(m,20000); |
- hard_task_def_mit(m,10000000); |
- PC_res_default_model(r,0); |
- SRP_res_default_model(srp,3); |
- p0 = task_createn("J1", j1, (TASK_MODEL *)&m, &r, &srp, SRP_usemutex(&m0), NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- hard_task_def_wcet(m,1600000); |
- hard_task_def_mit(m,21000000); |
- PC_res_default_model(r,1); |
- SRP_res_default_model(srp,2); |
- p1 = task_createn("J2", j2, (TASK_MODEL *)&m, &r, &srp, NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- hard_task_def_wcet(m,3000000); |
- hard_task_def_mit(m,100000000); |
- PC_res_default_model(r,2); |
- SRP_res_default_model(srp,1); |
- p2 = task_createn("J3", j3, (TASK_MODEL *)&m, &r, &srp, SRP_usemutex(&m0), NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create J3 task...\n"); return 1; } |
- |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p0); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p1); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 60); |
- |
- sys_end(); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/initfile.c (nonexistent) |
@@ -1,164 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/intdrive.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include "modules/pi.h" |
-#include "modules/pc.h" |
-#include "modules/srp.h" |
-#include "modules/npp.h" |
-#include "modules/nop.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- PI_register_module(); |
- PC_register_module(); |
- NPP_register_module(); |
- SRP_register_module(); |
- NOP_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/base/hello.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/hello.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/hello.c (nonexistent) |
@@ -1,53 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-/* |
- CVS : $Id: hello.c,v 1.1 2002-10-28 08:13:37 pj Exp $ |
- |
- hello.c: |
- |
- This test is a simple hello world function. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-int main(int argc, char **argv) |
-{ |
- cprintf("Hello, world!\n"); |
- |
- return 0; |
-} |
Index: tags/rel_1_4_rc1/base/pcdemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/pcdemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/pcdemo.c (nonexistent) |
@@ -1,203 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: pcdemo.c,v 1.3 2004-04-17 11:36:14 giacomo Exp $ |
- |
- This test verify the correctness of the PC module. |
- |
- The test uses 3 mutexes |
- m0 with ceiling 0 |
- m1 with ceiling 0 |
- m2 with ceiling 1 |
- |
- the main task (NRT) creates three tasks. |
- |
- J0 with PC priority 0 |
- starts at t=1.5 sec and lock m0, unlock m0, then lock and unlock m1 |
- |
- J1 with PC priority 1 |
- starts at t=0.5 sec and try to lock m2 |
- |
- J2 with PC priority 2 |
- it starts and locks m2 |
- at t=1 sec it locks m1 |
- at t=1.5 sec it unlocks m1 |
- |
- |
- The example is similar to the scheduling diagram shown at p. 197 of the |
- book "Sistemi in tempo Reale", by Giorgio Buttazzo, Pitagora Editrice |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-mutex_t m0,m1,m2; |
- |
-void startJ(void *a) |
-{ |
- task_activate((PID)a); |
-} |
- |
-TASK j0() |
-{ |
- cprintf("J0: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J0: locked m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J0: unlocked m0, locking m1\n"); |
- |
- mutex_lock(&m1); |
- cprintf("J0: locked m1\n"); |
- mutex_unlock(&m1); |
- cprintf("J0: unlocked m1, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("J1: locked m2\n"); |
- mutex_unlock(&m2); |
- cprintf("J1: unlocked m2, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
- cprintf("J2: before locking m2\n"); |
- mutex_lock(&m2); |
- cprintf("J2: locked m2, waiting to t=1 sec\n"); |
- |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J2: t = 1 sec reached\n"); |
- mutex_lock(&m1); |
- cprintf("J2: locked m1, waiting to t=2 sec\n"); |
- |
- while (sys_gettime(NULL) < 2000000); |
- |
- cprintf("J2: t = 2 sec reached\n"); |
- mutex_unlock(&m1); |
- cprintf("J2: unlocked m1\n"); |
- |
- mutex_unlock(&m2); |
- cprintf("J2: unlocked m2, end task\n"); |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- HARD_TASK_MODEL m; |
- PID p0,p1,p2; |
- |
- PC_mutexattr_t a; |
- PI_mutexattr_t a2; |
- PC_RES_MODEL r; |
- |
- clear(); |
- |
- cprintf("Priority Ceiling demo. It ends after 60 sec\n"); |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 1000000); |
- hard_task_def_wcet(m, 20000); |
- PC_res_default_model(r,0); |
- p0 = task_create("J0", j0, &m, &r); |
- if (p0 == NIL) |
- { cprintf("Can't create J0 task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 2100000); |
- hard_task_def_wcet(m, 20000); |
- PC_res_default_model(r,1); |
- p1 = task_create("J1", j1, &m, &r); |
- if (p1 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m, 10000000); |
- hard_task_def_wcet(m, 3000000); |
- PC_res_default_model(r,2); |
- p2 = task_create("J2", j2, &m, &r); |
- if (p2 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a2); |
- PC_mutexattr_default(a,0); |
- mutex_init(&m0,(mutexattr_t *)&a); |
- mutex_init(&m1,(mutexattr_t *)&a); |
- |
- PC_mutexattr_default(a,1); |
- mutex_init(&m2,(mutexattr_t *)&a); |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- t.tv_sec = 0; |
- t.tv_nsec = 500000000; |
- |
- kern_cli(); |
- kern_event_post(&t,startJ,(void *)p1); |
- |
- t.tv_sec = 1; |
- kern_event_post(&t,startJ,(void *)p0); |
- kern_sti(); |
- |
- task_activate(p2); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/base/readme |
=================================================================== |
--- tags/rel_1_4_rc1/base/readme (revision 1476) |
+++ tags/rel_1_4_rc1/base/readme (nonexistent) |
@@ -1,44 +0,0 @@ |
-This directory contains a set of simple examples, useful to understand |
-How to make a Shark application. |
- |
-Text mode demos: |
-- hello.c --> a hello world application |
-- timer.c --> tests if the time reads are always increasing |
- (useful for debugging purposes) |
-- sig.c --> simple example that sends signals |
-- semdemo.c --> simple example that uses a semaphore for mutual exclusion |
-- pidemo.c --> simple example that uses PI mutexes between NRT and Hard tasks |
-- pcdemo.c --> simple example that uses PC mutexes between NRT and Hard tasks |
-- srpdemo.c --> simple example that uses SRP mutexes between NRT and Hard tasks |
-- mdemo.c --> simple example that uses a mutex, initialized with whatever |
- protocol you want ;-) |
-- aster.c --> Wow! the original Hartik ASTER demo!!! (EDF, CABs, ...) |
-- aster1.c --> a -lot- of periodic tasks that are created and then die |
- (6 seconds demo) |
-- aster2.c --> a simple stress test: a lot of tasks are created until Utot=1; |
- uses jet functions to dump statistics. (60 seconds demo) |
-- aster3.c --> aster2 + 8 tasks handled by 2 different TBS servers |
-- aster4.c --> aster3 + CBS tasks + Shutdown demo with system tasks |
-- aster5.c --> aster3 + only CBS tasks + mutexes... Really interesting! |
-- aster6.c --> aster5 + Polling Server to serve the JetCtrl task |
-- aster7.c --> another aster clone with Rate monotonic and Polling server |
-- aster8.c --> aster5 + Sporadic Server |
-- preempt.c --> simple test for CBS, task_preempt, task_nopreempt, and |
- save/skip arrivals |
-- pcidemo.c --> PCI Bus scan |
-- jointest.c--> Simple test that uses the task_join primitive |
-- condtest.c--> Simple test that uses condition variables |
-- intsem.c --> Simple test that uses internal semaphores |
- |
-Graphical demos: |
-- fly.c --> Random flies going around the screen |
-- ego.c --> Periodic tasks that writes a phrease on the screen |
-- cabs.c --> Example that uses cabs |
- |
-Note on the init files: |
-- ihello.c (RR+dummy) |
-- isemdemo.c (iaster1+Semaphores) |
-- iaster1.c (EDF+RR+dummy) |
-- iaster3.c (EDF+RR+TBS(0.1)+TBS(0.3)+dummy) |
-- iaster4.c (iaster3+CBS) |
-- initfile.c (EDF+CBS+RR+dummy, SEMaphores, CABS, HARTPORTs and Keyboard) |
Index: tags/rel_1_4_rc1/base/pidemo.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/pidemo.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/pidemo.c (nonexistent) |
@@ -1,123 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: pidemo.c,v 1.3 2004-04-17 11:36:14 giacomo Exp $ |
- |
- This test verify the correctness of the PI module. |
- |
- the main task (NRT) lock a PI mutex. |
- then 2 tasks arrives, with priority higher than the main |
- |
- the first try to lock the mutex, but it can't, so the main inherit |
- his priority. The second simply prints a string. |
- |
- If all works, the string of the second task is printed after the end of |
- the first task. |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-mutex_t m1; |
- |
- |
-TASK goofy1(void *a) |
-{ |
- cprintf("goofy1 before mutex_lock\n"); |
- mutex_lock(&m1); |
- cprintf("goofy1 after mutex_lock\n"); |
- |
- mutex_unlock(&m1); |
- cprintf("goofy1 after mutex_unlock\n"); |
- |
- return 0; |
-} |
- |
-TASK goofy2() |
-{ |
- cprintf("goofy2 inside goofy2\n"); |
- return 0; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- HARD_TASK_MODEL m; |
- PID p2,p3; |
- |
- struct timespec t; |
- |
- PI_mutexattr_t a; |
- |
- hard_task_default_model(m); |
- hard_task_def_mit(m,50000); |
- hard_task_def_wcet(m,20000); |
- hard_task_def_group(m,1); |
- |
- hard_task_def_arg(m,(void *)1); |
- p2 = task_create("goofy1", goofy1, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create goofy1 task...\n"); return 1; } |
- |
- hard_task_def_mit(m,100000); |
- p3 = task_create("goofy2", goofy2, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create goofy2 task...\n"); return 1; } |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m1,&a); |
- |
- cprintf("main before mutex_lock\n"); |
- mutex_lock(&m1); |
- cprintf("main after mutex_lock\n"); |
- |
- group_activate(1); |
- |
- cprintf("main after group_activate\n"); |
- mutex_unlock(&m1); |
- cprintf("main after mutex_unlock\n"); |
- |
- mutex_destroy(&m1); |
- cprintf("main after mutex_destroy\n"); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/base/condtest.c |
=================================================================== |
--- tags/rel_1_4_rc1/base/condtest.c (revision 1476) |
+++ tags/rel_1_4_rc1/base/condtest.c (nonexistent) |
@@ -1,209 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- * |
- * CVS : $Id: condtest.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $ |
- |
- This test verify the correctness of the condition variables. |
- (... it doesn't test all...) |
- |
- The test uses 1 mutex |
- |
- the main task (NRT) creates three tasks. |
- |
- J0, J1, J3 |
- starts, lock the mutex, and wait on a condition variable |
- |
- J2 |
- at t = 0.5 lock the mutex and call cond_signal |
- at t = 1 lock the mutex and call cond_signal |
- |
-*/ |
- |
-#include "kernel/kern.h" |
- |
-mutex_t m0; |
-cond_t c0; |
- |
-int number = 0; |
- |
-PID p0,p1,p2,p3; |
- |
-TASK j0() |
-{ |
- cprintf("J0: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J0: locked m0, waiting on c0, number =%d\n", number); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J0: number = %d, if >0 unlocking m0\n",number); |
- } |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J0: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j1() |
-{ |
- cprintf("J1: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J1: locked m0, waiting on c0, number =%d\n", number); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J1: number = %d, if >0 unlocking m0\n",number); |
- } |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J1: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-TASK j2() |
-{ |
- |
- cprintf("J2: started, waiting t=0.5 sec\n"); |
- while (sys_gettime(NULL) < 500000); |
- |
- cprintf("J2: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J2: locked m0, number++ (was %d), cond_signal\n", number); |
- |
- number++; |
- cond_signal(&c0); |
- |
- cprintf("J2: unlocking m0\n"); |
- mutex_unlock(&m0); |
- |
- cprintf("J2: waiting t=1 sec\n"); |
- while (sys_gettime(NULL) < 1000000); |
- |
- cprintf("J2: Killing J3\n"); |
- task_kill(p3); |
- cprintf("J2: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J2: locked m0, number++ (was %d), cond_signal\n", number); |
- |
- number++; |
- cond_signal(&c0); |
- |
- cprintf("J2: unlocking m0\n"); |
- mutex_unlock(&m0); |
- cprintf("J2: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
-void cleanup_lock(void *arg) |
-{ |
- cprintf("J3: KILL!!!\n"); |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0 by the cleanup function\n"); |
-} |
- |
-TASK j3() |
-{ |
- cprintf("J3: before locking m0\n"); |
- mutex_lock(&m0); |
- cprintf("J3: locked m0, waiting on c0, number =%d\n", number); |
- task_cleanup_push(cleanup_lock, (void *)&m0); |
- while (!number) { |
- cond_wait(&c0,&m0); |
- cprintf("J3: number = %d, if >0 unlocking m0\n",number); |
- } |
- task_cleanup_pop(0); |
- // I hope this task never reach this point... it is killed by J2!!! |
- number--; |
- mutex_unlock(&m0); |
- cprintf("J3: unlocked m0, end task\n"); |
- return 0; |
-} |
- |
- |
-int main(int argc, char **argv) |
-{ |
- struct timespec t; |
- |
- NRT_TASK_MODEL m; |
- |
- PI_mutexattr_t a; |
- |
- /* --------------------------------------------------------------------- |
- Task creation |
- --------------------------------------------------------------------- */ |
- |
- nrt_task_default_model(m); |
- nrt_task_def_group(m,1); |
- p0 = task_create("J0", j0, &m, NULL); |
- if (p0 == NIL) |
- { cprintf("Can't create J0 task...\n"); return 1; } |
- |
- p1 = task_create("J1", j1, &m, NULL); |
- if (p1 == NIL) |
- { cprintf("Can't create J1 task...\n"); return 1; } |
- |
- p2 = task_create("J2", j2, &m, NULL); |
- if (p2 == NIL) |
- { cprintf("Can't create J2 task...\n"); return 1; } |
- |
- p3 = task_create("J3", j3, &m, NULL); |
- if (p3 == NIL) |
- { cprintf("Can't create J3 task...\n"); return 1; } |
- |
- /* --------------------------------------------------------------------- |
- Mutex creation |
- --------------------------------------------------------------------- */ |
- |
- PI_mutexattr_default(a); |
- mutex_init(&m0,&a); |
- |
- cond_init(&c0); |
- |
- /* --------------------------------------------------------------------- |
- Event post |
- --------------------------------------------------------------------- */ |
- |
- group_activate(1); |
- |
- do { |
- sys_gettime(&t); |
- } while (t.tv_sec < 10); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/readme.txt (nonexistent) |
@@ -1,7 +0,0 @@ |
-Hi, these are the S.Ha.R.K. demos... |
- |
-the old examples directory is now called demos/oldexamples... |
- |
-Enjoy |
- |
-PJ |
Index: tags/rel_1_4_rc1/advtimer/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/advtimer/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/advtimer/initfile.c (nonexistent) |
@@ -1,178 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/hardcbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "drivers/shark_linuxc26.h" |
-#include "drivers/shark_input26.h" |
-#include "drivers/shark_keyb26.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 1000 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ IntDrive Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAGS 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAGS); |
- EDF_register_level(EDF_ENABLE_ALL); |
- HCBS_register_level(HCBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- CABS_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- //sys_set_reboot(EXIT_MODE_HALT); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
- |
Index: tags/rel_1_4_rc1/advtimer/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/advtimer/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/advtimer/readme.txt (nonexistent) |
@@ -1,31 +0,0 @@ |
--------------------------------------- |
-Advanced Timer Demo |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 23/04/2003 |
--------------------------------------- |
- |
-This demo shows the new timer management |
-code of S.Ha.R.K. |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-ADVTIMER.C The Advanced Timer Demo |
- |
--------------------------------------- |
- |
-To change the timer mode, you have to |
-modify shark.cfg and to recompile the |
-system |
- |
-make clean |
-make |
- |
Index: tags/rel_1_4_rc1/advtimer/advtimer.c |
=================================================================== |
--- tags/rel_1_4_rc1/advtimer/advtimer.c (revision 1476) |
+++ tags/rel_1_4_rc1/advtimer/advtimer.c (nonexistent) |
@@ -1,161 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-/* |
- * Advanced Timer Demo |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "ll/i386/cons.h" |
-#include "ll/i386/advtimer.h" |
- |
-#include "drivers/shark_keyb26.h" |
- |
-#define UPDATE_PERIOD 10000 |
-#define UPDATE_WCET 1000 |
- |
-extern unsigned int clk_per_msec; |
-extern unsigned int apic_clk_per_msec; |
- |
-TASK Update(void *arg) |
-{ |
- struct timespec actual_timer; |
- |
- long nsec,sec,min,hrs,day; |
- long mean_delay,tot_delay,num_delay; |
- |
- signed long long start,end,res; |
- struct timespec s_test,startts,endts; |
- |
- task_nopreempt(); |
- |
- num_delay = tot_delay = mean_delay = 0; |
- |
- while (1) { |
- |
- if (clk_per_msec != 0) { |
- |
- rdtscll(start); |
- sys_gettime(&actual_timer); |
- rdtscll(end); |
- res = end - start; |
- rdtscll(start); |
- rdtscll(end); |
- res -= (end - start); |
- s_test.tv_nsec = res * 1000000 / clk_per_msec; |
- |
- |
- } else { |
- |
- sys_gettime(&startts); |
- sys_gettime(&actual_timer); |
- sys_gettime(&endts); |
- SUBTIMESPEC(&endts,&startts,&s_test); |
- sys_gettime(&startts); |
- sys_gettime(&endts); |
- SUBTIMESPEC(&endts,&startts,&endts); |
- SUBTIMESPEC(&s_test,&endts,&s_test); |
- |
- } |
- |
- if (tot_delay < 1000000000) { |
- tot_delay += s_test.tv_nsec; |
- num_delay ++; |
- mean_delay = tot_delay / num_delay; |
- } |
- |
- nsec = actual_timer.tv_nsec; |
- sec = actual_timer.tv_sec; |
- min = sec / 60; |
- sec %= 60; |
- hrs = min / 60; |
- min %= 60; |
- day = hrs / 24; |
- hrs %= 24; |
- |
- printf_xy(0,5,WHITE,"Actual CPU Clk/msec: %12d",clk_per_msec); |
- printf_xy(0,6,WHITE,"Actual APIC Clk/msec: %12d",apic_clk_per_msec); |
- printf_xy(0,7,WHITE,"Actual Timer: %2ld d %2ld h %2ld m %2ld s %12ld ns",day,hrs,min,sec,(long)nsec); |
- |
- printf_xy(0,9,WHITE,"Timer Access Delay: %12ld ns",mean_delay); |
- |
- task_endcycle(); |
- |
- } |
- |
-} |
- |
-void set_screen() |
-{ |
- |
- clear(); |
- |
- printf_xy(20,0,WHITE," Advanced Timer Demo "); |
- printf_xy(20,1,WHITE,"Giacomo Guidi <giacomo@gandalf.sssup.it>"); |
- printf_xy(20,2,WHITE," Press Alt + c to exit "); |
- |
-} |
- |
-void program_key_end(KEY_EVT* e) |
-{ |
- sys_end(); |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- HARD_TASK_MODEL mp; //Show current setting |
- PID update; |
- KEY_EVT k; |
- |
- k.flag = ALTL_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,program_key_end,FALSE); |
- |
- set_screen(); |
- |
- hard_task_default_model(mp); |
- hard_task_def_ctrl_jet(mp); |
- hard_task_def_group(mp, 1); |
- hard_task_def_wcet(mp,UPDATE_WCET); |
- hard_task_def_mit(mp,UPDATE_PERIOD); |
- hard_task_def_usemath(mp); |
- update = task_create("Update", Update, &mp, NULL); |
- if (update != NIL) task_activate(update); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/advtimer/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/advtimer/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/advtimer/makefile (nonexistent) |
@@ -1,17 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = advtimer |
- |
-include $(BASE)/config/example.mk |
- |
-# Text applications |
-advtimer: |
- make -f $(SUBMAKE) APP=advtimer INIT= OTHEROBJS="initfile.o" SHARKOPT="__LINUXC26__ __PCI__ __INPUT__" |
- |
Index: tags/rel_1_4_rc1/tftptest/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/tftptest/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/tftptest/initfile.c (nonexistent) |
@@ -1,161 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * Authors : Mauro Marinoni <mauro.marinoni@unipv.it> |
- * (see authors.txt for full list of hartik's authors) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
- |
-#include <kernel/kern.h> |
- |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/intdrive.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = 1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-int device_drivers_close() { |
- |
- KEYB26_close(); |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_init() { |
- |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- PCI26_init(); |
- INPUT26_init(); |
- |
- /*keyb_def_map(kparms, KEYMAP_IT);*/ |
- keyb_def_ctrlC(kparms, NULL); |
- KEYB26_init(&kparms); |
- |
- return 0; |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- sys_abort_shutdown(0); |
- |
- return NULL; |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-void call_shutdown_task(void *arg) { |
- |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
Index: tags/rel_1_4_rc1/tftptest/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/tftptest/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/tftptest/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = tftptest |
- |
-include $(BASE)/config/example.mk |
- |
-tftptest: |
- make -f $(SUBMAKE) APP=tftptest INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __NET__ __INPUT__ __TFTP__" |
- |
Index: tags/rel_1_4_rc1/tftptest/tftptest.c |
=================================================================== |
--- tags/rel_1_4_rc1/tftptest/tftptest.c (revision 1476) |
+++ tags/rel_1_4_rc1/tftptest/tftptest.c (nonexistent) |
@@ -1,226 +0,0 @@ |
-#include <string.h> |
-#include <kernel/func.h> |
-#include <kernel/kern.h> |
- |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/udpip.h> |
- |
-#include "tftp.h" |
-#include "endian.h" |
- |
-#include "modules/sem.h" |
- |
-#include <kernel/kern.h> |
-#include <ll/i386/hw-instr.h> |
- |
- |
-#define LOCAL_HOST_IP "192.168.0.134" |
-#define REMOTE_HOST_IP "192.168.0.133" |
- |
-sem_t m1, m2; |
-int handle, handle2; |
- |
-int prog = 0; |
- |
-/* This function is called when the user presses CTRL-C (stops the systems) */ |
- |
-void esci(KEY_EVT *k) |
-{ |
- sys_shutdown_message("Exit from the program...\n"); |
- sys_shutdown_message("Ctrl-C pressed!\n"); |
- sys_end(); |
-} |
- |
-void augprog(KEY_EVT *k) |
-{ |
- prog = 1; |
-} |
- |
-void keyb_start(void) { |
- KEY_EVT k; |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_C; |
- k.status = KEY_PRESSED; |
- k.ascii = 'C'; |
- keyb_hook(k, esci,FALSE); |
- k.flag = CNTR_BIT; |
- k.scan = KEY_C; |
- k.ascii = 'c'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k, esci,FALSE); |
- |
- k.flag = CNTL_BIT; |
- k.scan = KEY_A; |
- k.ascii = 'A'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k, augprog,FALSE); |
- k.flag = CNTR_BIT; |
- k.scan = KEY_A; |
- k.ascii = 'a'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k, augprog,FALSE); |
-} |
- |
-TASK test_upload(void *arg) { |
- int i; |
- char msg[200]; |
- int bytes; |
- |
- i = 0; |
- while (1) { |
- |
-// cprintf("uploader 1\n"); |
- |
- sprintf(msg, "tftptest says: i = %5d\n", i); |
- tftp_put(handle, msg, strlen(msg)); |
- |
-// cprintf("uploader 2\n"); |
- |
- bytes = tftp_usedbuffer(handle); |
- /*!*/sprintf(msg, "buffer %d ", bytes); |
- /*!*/puts_xy(BASE_X, 18, WHITE, msg); |
- |
-// cprintf("uploader 3\n"); |
- i++; |
- |
- task_endcycle(); |
- } |
- return(0); |
-} |
- |
-TASK test_upload2(void *arg) { |
- int i; |
- char msg[200]; |
- int bytes; |
- |
- i = 0; |
- while (1) { |
- |
- sprintf(msg, "tftptest says: i = %5d\n", i); |
- tftp_put(handle2, msg, strlen(msg)); |
- |
- bytes = tftp_usedbuffer(handle2); |
- /*!*/sprintf(msg, "buffer2 %d ", bytes); |
- /*!*/puts_xy(BASE_X, 38, WHITE, msg); |
- i++; |
- |
- task_endcycle(); |
- } |
- return(0); |
-} |
- |
-void wait() { |
- char ch; |
- do { |
- ch = keyb_getch(NON_BLOCK); |
- } while(prog == 0); |
- prog = 0; |
-} |
- |
-int main(void) |
-{ |
- int err; |
- HARD_TASK_MODEL hard_m; |
- PID p1, p2; |
- |
- keyb_start(); |
- cprintf("main: Keyboard handler started\n"); |
- |
- tftp_init(); |
- cprintf("main: Tftp library initialized\n"); |
- |
- err = tftp_net_start(LOCAL_HOST_IP, REMOTE_HOST_IP, 1); |
- cprintf("netval = %d\n", err); |
- if (err == 1) { |
- cprintf("Net Init from %s to %s\n", LOCAL_HOST_IP, REMOTE_HOST_IP); |
- } else { |
- cprintf("Net Init Failed...\n"); |
- sys_end(); |
- return(err); |
- } |
- |
- sem_init(&m1, 0, 1); |
- |
- |
- if ((handle = tftp_open("test.txt")) == -1) { |
- cprintf("No slots available. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- |
- cprintf("Ctrl-A to proceed *** Ctrl-C to stop\n"); |
- wait(); |
- clear(); |
- |
- cprintf("Handle = %d\n", handle); |
- |
- if ((err = tftp_upload(handle, 4096, &m1)) != 0) { |
- cprintf("Error %d calling tftp_upload(). Program aborted...\n", err); |
- sys_end(); |
- return(1); |
- } |
- |
- /* First we set the sender's task properties...*/ |
- hard_task_default_model(hard_m); |
- hard_task_def_wcet(hard_m, 10000); |
- hard_task_def_mit(hard_m, 300000); |
- |
- if ((p1 = task_create("test_upload", test_upload, &hard_m, NULL)) == NIL) { |
- cprintf("Error creating test_upload task. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- if (task_activate(p1) == -1) { |
- cprintf("Error activating test_upload task. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- |
- |
- sem_init(&m2, 0, 1); |
- |
- if ((handle2 = tftp_open("test2.txt")) == -1) { |
- cprintf("No second slot available. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- |
- |
- |
- cprintf("Handle2 = %d\n", handle2); |
- |
- if ((err = tftp_upload(handle2, 4096, &m2)) != 0) { |
- cprintf("Error %d calling tftp_upload(). Program aborted...\n", err); |
- sys_end(); |
- return(1); |
- } |
- |
- /* First we set the sender's task properties...*/ |
- hard_task_default_model(hard_m); |
- hard_task_def_wcet(hard_m, 10000); |
- hard_task_def_mit(hard_m, 300000); |
- |
- if ((p2 = task_create("test_upload2", test_upload2, &hard_m, NULL)) == NIL) { |
- cprintf("Error creating test_upload2 task. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- if (task_activate(p2) == -1) { |
- cprintf("Error activating test_upload2 task. Program aborted...\n"); |
- sys_end(); |
- return(1); |
- } |
- |
- |
- wait(); |
- |
- tftp_close(handle, TFTP_STOP_NOW); |
- |
- tftp_close(handle2, TFTP_STOP_NOW); |
- |
- cprintf("\nProgram terminated correctly.\n"); |
- sys_end(); |
- |
- return(0); |
-} |
Index: tags/rel_1_4_rc1/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/makefile (nonexistent) |
@@ -1,28 +0,0 @@ |
-include ../shark.cfg |
- |
-ifeq ($(findstring NEW,$(TRACER)) , NEW) |
-TRC = newtrace |
-endif |
- |
-dirs := $(filter-out CVS cvs makefile readme.txt newtrace README.TXT, $(wildcard *)) |
-dirs += $(TRC) |
-p_all := $(addprefix prefixall_, $(dirs)) |
-p_install := $(addprefix prefixinstall_, $(dirs)) |
-p_clean := $(addprefix prefixclean_, $(dirs)) |
-pcleanall := $(addprefix prefixcleanall_, $(dirs)) |
-pdepend := $(addprefix prefixdepend_, $(dirs)) |
- |
- |
-.PHONY: all clean |
- |
- |
- |
-all: $(p_all) |
- |
-clean: $(p_clean) |
- |
-prefixall_%: |
- make -C $* |
- |
-prefixclean_%: |
- make -C $* clean |
Index: tags/rel_1_4_rc1/dosfs/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/dosfs/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/dosfs/readme.txt (nonexistent) |
@@ -1,46 +0,0 @@ |
--------------------------------------- |
-DOS_fXXX Demo |
- |
-by |
- |
-Paolo Gai pj@sssup.it |
-and |
-Gabriele Bolognini gabrieleb@sssup.it |
-2001 |
- |
--------------------------------------- |
- |
-The DOS_fXXX functions provided into ll/i386/x-dos.h are a few |
-shortcuts that can be used to call INT21's DOS calls. |
- |
-These functions can be used to read and write files before/after |
-the kernel goes into i386 protected mode. |
- |
-THEY CANNOT BE USED IF YOU BOOT WITH GRUB. |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application; |
- dosfs is the rule to compile the application |
-README.TXT This file |
-INITFILE.C The init file (only RR) |
-DOSFS.C The DOS_fread and DOS_fwrite demo |
- |
--------------------------------------- |
- |
-The demo works as follows: |
-- Into __kernel_register_levels__() the demo reads up to 1000 bytes from |
- myfile.txt |
-- Then, into the main() function it prints the contents of the buffer at |
- screen |
-- Finally, at the end of the system it writes a file called myfile.out |
- with up to 30 of the first bytes of the buffer |
- |
-The demo should work on any processor speed, and does not use keyboard or |
-graphics. |
- |
-Bug: at the moment (01 Jun 2001) sometimes the demo hangs when using |
-the one-shot timer. |
- |
Index: tags/rel_1_4_rc1/dosfs/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/dosfs/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/dosfs/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= dosfs |
- |
-include $(BASE)/config/example.mk |
- |
-dosfs: |
- make -f $(SUBMAKE) APP=dosfs INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT= |
- |
Index: tags/rel_1_4_rc1/dosfs/dosfs.c |
=================================================================== |
--- tags/rel_1_4_rc1/dosfs/dosfs.c (revision 1476) |
+++ tags/rel_1_4_rc1/dosfs/dosfs.c (nonexistent) |
@@ -1,174 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: dosfs.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Gabriele Bolognini |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "string.h" |
-#include "ll/i386/x-dos.h" |
- |
- |
-/* This is the buffer used by read_myfile */ |
-char myfilebuf[1000]; |
- |
-/* This is the number of bytes read by read_myfile */ |
-int myfilebuf_length; |
- |
-/* This function write myfile.out (up to 30 chars) */ |
-void write_myfile(void *arg); |
- |
-int main(int argc, char **argv) |
-{ |
- int x; |
- |
- cprintf("\nBuffer contents:\n"); |
- |
- for (x=0; x<myfilebuf_length; x++) |
- cputc(myfilebuf[x]); |
- |
- /* |
- WARNING: You can call these functions only when you are in |
- real mode!!! |
- |
- The system is in real mode: |
- - into __kernel_register_levels__() |
- - into sys_atrunlevel functions posted with RUNLEVEL_AFTER_EXIT |
- */ |
- |
- if (myfilebuf_length) |
- sys_atrunlevel(write_myfile, NULL, RUNLEVEL_AFTER_EXIT); |
- |
- return 0; |
- /* |
- * Since there is only one user task, the kernel will shut down after this |
- * task finishes... |
- */ |
-} |
- |
-/* This function read myfile.txt (up to 1000 chars) */ |
-void read_myfile(void) |
-{ |
- /* DOS file descriptor */ |
- DOS_FILE *f; |
- |
- /* Error code */ |
- int err; |
- |
- /* open the DOS file for reading (you can specify only "r" or "w") */ |
- f = DOS_fopen("myfile.txt","r"); |
- |
- /* check for open errors */ |
- if (!f) { |
- /* error!! */ |
- err = DOS_error(); |
- |
- /* note that if you call DOS_error() here, it return 0!!! */ |
- cprintf("Error %d opening myfile.txt...\n", err); |
- myfilebuf_length = 0; |
- return; |
- } |
- |
- /* read up to 1000 chars */ |
- myfilebuf_length = DOS_fread(&myfilebuf,1,1000,f); |
- |
- /* check for errors */ |
- err = DOS_error(); |
- |
- cprintf("Read %d bytes from myfile.txt...\n", myfilebuf_length); |
- |
- if (err) { |
- cprintf("Error %d reading myfile.txt...\n", err); |
- myfilebuf_length = 0; |
- /* there is not return because I want to close the file! */ |
- } |
- |
- /* Close the file */ |
- DOS_fclose(f); |
-} |
- |
-/* This function write myfile.out (up to 30 chars) */ |
-void write_myfile(void *arg) |
-{ |
- DOS_FILE *f; /* DOS file descriptor */ |
- int err; /* Error code */ |
- int maxbytes; |
- int writtenbytes; /* number of files written */ |
- |
- /* open the DOS file for writing (you can specify only "r" or "w") */ |
- f = DOS_fopen("myfile.out","w"); |
- |
- /* check for open errors */ |
- if (!f) { |
- /* error!! */ |
- err = DOS_error(); |
- |
- /* note that if you call DOS_error() here, it return 0!!! */ |
- cprintf("Error %d opening myfile.out...\n", err); |
- return; |
- } |
- |
- /* write up to 30 bytes */ |
- if (myfilebuf_length > 30) |
- maxbytes = 30; |
- else |
- maxbytes = myfilebuf_length; |
- |
- writtenbytes = DOS_fwrite(myfilebuf,1,maxbytes,f); |
- |
- /* check for errors */ |
- err = DOS_error(); |
- |
- cprintf("Written %d bytes into myfile.out...\n", writtenbytes); |
- |
- if (err) { |
- cprintf("Error %d writing myfile.txt...\n", err); |
- /* there is not return because I want to close the file! */ |
- } |
- |
- /* Close the file */ |
- DOS_fclose(f); |
-} |
- |
- |
Index: tags/rel_1_4_rc1/dosfs/myfile.txt |
=================================================================== |
--- tags/rel_1_4_rc1/dosfs/myfile.txt (revision 1476) |
+++ tags/rel_1_4_rc1/dosfs/myfile.txt (nonexistent) |
@@ -1,3 +0,0 @@ |
-0.2.4.6.8.0.2.4.6.8.0.2.4.6.8.0.2.4.6.8. |
-This is the myfile.txt file... |
- |
Index: tags/rel_1_4_rc1/dosfs/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/dosfs/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/dosfs/initfile.c (nonexistent) |
@@ -1,91 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/** |
- ------------ |
- CVS : $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.1.1.1 $ |
- Last update: $Date: 2002-09-02 09:37:41 $ |
- ------------ |
-**/ |
- |
-/* |
- * Copyright (C) 2000 Paolo Gai and Gabriele Bolognini |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-void read_myfile(void); |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- /* If you need to interact with the DOS Filesystem and you use |
- the X eXtender, this is the better place where you can use |
- the DOS_fXXX functions... |
- |
- WARNING: You can call these functions only when you are in |
- real mode!!! |
- |
- The system is in real mode: |
- - into __kernel_register_levels__() |
- - into sys_atrunlevel functions posted with RUNLEVEL_AFTER_EXIT |
- */ |
- read_myfile(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
Index: tags/rel_1_4_rc1/orbit/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/orbit/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/orbit/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= orbit |
- |
-include $(BASE)/config/example.mk |
- |
-orbit: |
- make -f $(SUBMAKE) APP=orbit INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
Index: tags/rel_1_4_rc1/orbit/orbit.c |
=================================================================== |
--- tags/rel_1_4_rc1/orbit/orbit.c (revision 1476) |
+++ tags/rel_1_4_rc1/orbit/orbit.c (nonexistent) |
@@ -1,351 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- ------------ |
- CVS : $Id: orbit.c,v 1.8 2004-05-23 19:30:33 giacomo Exp $ |
- |
- File: $File$ |
- Revision: $Revision: 1.8 $ |
- Last update: $Date: 2004-05-23 19:30:33 $ |
- ------------ |
-*/ |
- |
-/* |
- * Copyright (C) 2000 Giorgio Buttazzo and Paolo Gai |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/****************************************************************/ |
-/* SIMULAZIONE DI MASSE CHE ORBITANO */ |
-/****************************************************************/ |
- |
-#include <kernel/kern.h> |
-#include <semaphore.h> |
-#include <stdlib.h> |
-#include <math.h> |
-#include <string.h> |
- |
-#include <drivers/shark_fb26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-#define MAX 11 /* numero massimo pianeti */ |
-#define XMAX 639 /* valore massimo coordinata X */ |
-#define YMAX 479 /* valore massimo coordinata Y */ |
- |
-extern int vga16color[16]; |
- |
-struct coord { |
- double x; |
- double y; |
-}; |
- |
-int flen; // file length |
- |
-double mass[MAX]; /* vettore masse pianeti */ |
-struct coord pos[MAX]; /* vettore posizioni attuali */ |
-struct coord vel[MAX]; /* vettore velocita' iniziali */ |
- |
-int XGS, YGS; /* Coordinate centro spazio */ |
-int RP, RT; /* raggio pianeta, raggio Terra */ |
-int np; /* numero attuale di pianeti */ |
-double G; /* Gravitazione Universale */ |
-double tick; /* tick di sistema */ |
-double delta; /* incremento temporale */ |
-double scala; /* fattore grafico di scala */ |
- |
-char fbuf[1000] ="\ |
-----------------------------------------------------\n\ |
-period: 10000 wcet: 500\n\ |
-delta: 1. scala: 150.\n\ |
-G: 6.6e-15\n\ |
-r_pianeta: 4 r_Terra: 8\n\ |
-X_centro: 320 Y_centro: 240\n\ |
-------------------- pianeti ------------------------\n\ |
- massa pos.x pos.y vel.x vel.y\n\ |
-0: \t 6.0e21 \t 0. \t 0. \t 0. \t 0. \n\ |
-1: \t 1.0e21 \t 10000. \t 8000. \t -60. \t 0. \n\ |
-2: \t 1.0e8 \t 5000. \t 0. \t 0. \t 80. \n\ |
-3: \t 5.0e18 \t 10000. \t 8000. \t -50. \t 0. \n\ |
-4: \t 1.0e9 \t 10000. \t 8000. \t -40. \t 20. \n\ |
-5: \t 1.0e15 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-6: \t 1.0e5 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-7: \t 1.0e17 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-8: \t 1.0e5 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-9: \t 1.0e5 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-10: \t 1.0e5 \t 1000. \t 5000. \t -80. \t 0. \n\ |
-----------------------------------------------------\n"; |
- |
-// ------------------------------------------------------- |
-// NOTA: %f o %lf significa double e %nf significa float |
-// ------------------------------------------------------- |
- |
-PID pid; |
-int period; /* task period */ |
-int wcet; /* task wcet */ |
-sem_t mutex; /* semaforo di mutua esclusione */ |
- |
- |
-void get_par(void); |
- |
-/*--------------------------------------------------------------*/ |
- |
-int inside(int x, int y) |
-{ |
- return ((x > RP) && (x < XMAX-RP) && |
- (y > RP) && (y < YMAX-RP)); |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
-TASK massa(void *xxx) |
-{ |
- int i = (int)xxx; /* parametro del task */ |
- int gx, gy; /* coordinate grafiche pallina */ |
- int ox, oy; /* vecchia posizione pallina */ |
- int j; |
- int r, col; /* raggio e colore pianeta */ |
- double dt; /* incremento temporale */ |
- double dist=0.0, dx, dy; /* distanze pianeta-pianeta */ |
- double dist0=0.0; /* distanze pianeta-Terra */ |
- double x, y; /* posizione del pianeta */ |
- double vx, vy; /* velocita' del pianeta */ |
- double ax, ay; /* accelerazione del pianeta */ |
- double k; /* variabile ausiliaria */ |
- double arg; /* variabile di appoggio */ |
- |
- x = pos[i].x; y = pos[i].y; |
- vx = vel[i].x; vy = vel[i].y; |
- ox = XGS + x / scala; |
- oy = YGS + y / scala; |
- dt = delta; |
- |
- do { |
- x = pos[i].x; |
- y = pos[i].y; |
- ax = ay = 0.0; |
- for (j=0; j<np; j++) { |
- if (j != i) { |
- dx = pos[j].x - x; |
- dy = pos[j].y - y; |
- arg = dx*dx + dy*dy; |
- dist = sqrt(arg); |
- if (dist < RP*scala) dist = RP*scala; |
- k = G * mass[j] / (dist*dist*dist); |
- ax += k * dx; |
- ay += k * dy; |
- } |
- if (j == 0) dist0 = dist - (RP+RT)*scala; |
- } |
- x += vx*dt + 0.5*ax*dt*dt; |
- y += vy*dt + 0.5*ay*dt*dt; |
- vx += ax * dt; |
- vy += ay * dt; |
- |
- gx = XGS + x / scala; |
- gy = YGS + y / scala; |
- |
- r = RP; |
- col = i + 1; |
- |
- sem_wait(&mutex); |
- grx_disc(ox,oy,r,vga16color[0]); |
- grx_disc(gx,gy,r,vga16color[col]); |
- sem_post(&mutex); |
- |
- pos[i].x = x; pos[i].y = y; |
- ox = gx; oy = gy; |
- |
- task_endcycle(); |
- |
- } while ((dist0 > 0) && inside(gx,gy)); |
- |
- sem_wait(&mutex); |
- grx_disc(ox,oy,r,vga16color[0]); |
- grx_disc(XGS,YGS,RT,vga16color[12]); |
- grx_circle(XGS,YGS,RT,vga16color[14]); |
- sem_post(&mutex); |
- |
- return NULL; |
-} |
- |
-/*--------------------------------------------------------------*/ |
-/* MAIN */ |
-/*--------------------------------------------------------------*/ |
- |
-int main() |
-{ |
- HARD_TASK_MODEL m; |
- char c; /* carattere letto da tastiera */ |
- |
- sem_init(&mutex,0,1); |
- |
- get_par(); |
- |
- grx_disc(XGS,YGS,RT,vga16color[12]); |
- grx_circle(XGS,YGS,RT,vga16color[14]); |
- |
- np = 0; |
- |
- do { |
- if (np < MAX-1) { |
- np++; |
- hard_task_default_model(m); |
- hard_task_def_arg (m, (void *)np); |
- hard_task_def_wcet (m, wcet); |
- hard_task_def_mit (m, period); |
- hard_task_def_usemath (m); |
- pid = task_create("massa", massa, &m, NULL); |
- if (pid == NIL) { |
- sys_shutdown_message("Could not create task"); |
- sys_end(); |
- } |
- task_activate(pid); |
- } |
- c = keyb_getch(BLOCK); |
- |
- } while (c != ESC); |
- |
- sys_end(); |
- |
- return 0; |
-} |
- |
-/*------------------------------------------------------*/ |
-/* file reading */ |
-/*------------------------------------------------------*/ |
- |
-void read_file(void) |
-{ |
- int err; |
- DOS_FILE *fp; |
- |
- fp = DOS_fopen("orbit.dat","r"); |
- |
- if (!fp) { |
- err = DOS_error(); |
- cprintf("Error %d opening myfile.txt...\n", err); |
- flen = 0; |
- return; |
- } |
- |
- flen = DOS_fread(&fbuf, 1, 1000, fp); |
- cprintf("Read %d bytes from orbit.dat\n", flen); |
- |
- DOS_fclose(fp); |
-} |
- |
-/*------------------------------------------------------*/ |
-/* get data from buffer */ |
-/*------------------------------------------------------*/ |
- |
-void get_par(void) |
-{ |
- int x = 0; |
- int i; |
- double vx, vy, px, py; |
- |
- flen = strlen(fbuf); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &period); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &wcet); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &delta); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &scala); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &G); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &RP); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &RT); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &XGS); |
- |
- while ((fbuf[x] != ':') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%d", &YGS); |
- |
- for (i=0; i<MAX; i++) { |
- |
- mass[i] = 0.; |
- px = 0.; |
- py = 0.; |
- vx = 0.; |
- vy = 0.; |
- |
- while ((fbuf[x] != '\t') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &mass[i]); |
- |
- while ((fbuf[x] != '\t') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &px); |
- |
- while ((fbuf[x] != '\t') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &py); |
- |
- while ((fbuf[x] != '\t') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &vx); |
- |
- while ((fbuf[x] != '\t') && (x < flen)) x++; |
- x++; |
- sscanf(&fbuf[x], "%lf", &vy); |
- |
- pos[i].x = px; pos[i].y = py; |
- |
- vel[i].x = vx; vel[i].y = vy; |
- |
- } |
-} |
- |
-/*--------------------------------------------------------------*/ |
- |
Index: tags/rel_1_4_rc1/orbit/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/orbit/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/orbit/initfile.c (nonexistent) |
@@ -1,200 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/hardcbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- HCBS_register_level(HCBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- |
- //read_file(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/orbit/orbit.dat |
=================================================================== |
--- tags/rel_1_4_rc1/orbit/orbit.dat (revision 1476) |
+++ tags/rel_1_4_rc1/orbit/orbit.dat (nonexistent) |
@@ -1,21 +0,0 @@ |
----------------------------------------------------- |
-period: 10000 wcet: 100 |
-delta: 1. scala: 150. |
-G: 6.6e-15 |
-r_pianeta: 4 r_Terra: 8 |
-X_centro: 320 Y_centro: 240 |
- |
-------------------- pianeti ------------------------ |
- massa pos.x pos.y vel.x vel.y |
-0: 6.0e21 0. 0. 0. 0. |
-1: 1.0e21 10000. 8000. -60. 0. |
-2: 1.0e8 5000. 0. 0. 80. |
-3: 5.0e18 10000. 8000. -50. 0. |
-4: 1.0e9 10000. 8000. -40. 20. |
-5: 1.0e15 1000. 5000. -80. 0. |
-6: 1.0e5 1000. 5000. -80. 0. |
-7: 1.0e17 1000. 5000. -80. 0. |
-8: 1.0e5 1000. 5000. -80. 0. |
-9: 1.0e5 1000. 5000. -80. 0. |
-10: 1.0e5 1000. 5000. -80. 0. |
----------------------------------------------------- |
Index: tags/rel_1_4_rc1/bttvdemo/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/bttvdemo/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/bttvdemo/initfile.c (nonexistent) |
@@ -1,177 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K |
- * |
- * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://hartik.sssup.it |
- */ |
- |
-#include "kernel/kern.h" |
-#include "modules/edf.h" |
-#include "modules/cbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
-#include "modules/intdrive.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
-#include <drivers/shark_i2c26.h> |
-#include <drivers/shark_bttv26.h> |
-#include <drivers/shark_videodev26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
-#define FRAME_GRABBER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 10000 |
- |
-/*+ Interrup Server */ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- CBS_register_level(CBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- set_shutdown_task(); |
- |
- device_drivers_init(); |
- |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-void set_shutdown_task() { |
- |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- I2C26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- BTTV26_init(); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- BTTV26_close(); |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/bttvdemo/readme.txt |
=================================================================== |
--- tags/rel_1_4_rc1/bttvdemo/readme.txt (revision 1476) |
+++ tags/rel_1_4_rc1/bttvdemo/readme.txt (nonexistent) |
@@ -1,31 +0,0 @@ |
--------------------------------------- |
-BTTV Frame Grabber Demo |
- |
-by |
- |
-Giacomo Guidi <giacomo@gandalf.sssup.it> |
- |
-Last update 12/05/2004 |
--------------------------------------- |
-Ex: |
- |
-x bttv [channel number] |
- |
-if the channel is not specified 0 is taken. |
-If you don't see a grabbed image, you |
-can try to set a channel number from 0 to 4. |
- |
-This is a simple demo for the BTTV driver. |
-It starts the frame grabber at 25 fps 320x200. |
- |
--------------------------------------- |
- |
-The demo is composed by: |
- |
-MAKEFILE The makefile used to compile the application |
-README.TXT This file |
-INITFILE.C The init file |
-BTTV.C The BTTV Demo |
- |
--------------------------------------- |
- |
Index: tags/rel_1_4_rc1/bttvdemo/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/bttvdemo/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/bttvdemo/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS = bttv |
- |
-include $(BASE)/config/example.mk |
- |
-bttv: |
- make -f $(SUBMAKE) APP=bttv INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__ __I2C__ __BTTV__" |
- |
Index: tags/rel_1_4_rc1/bttvdemo/bttv.c |
=================================================================== |
--- tags/rel_1_4_rc1/bttvdemo/bttv.c (revision 1476) |
+++ tags/rel_1_4_rc1/bttvdemo/bttv.c (nonexistent) |
@@ -1,315 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * Copyright (C) 2003 Giacomo Guidi |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- */ |
- |
-#include "kernel/kern.h" |
-#include "stdlib.h" |
-#include "unistd.h" |
- |
-#include "drivers/shark_keyb26.h" |
-#include "drivers/shark_videodev26.h" |
-#include "drivers/shark_fb26.h" |
- |
-#include "tracer.h" |
- |
-#define WIDTH 640 |
-#define HEIGHT 480 |
-#define BYTES_PP 2 |
- |
-//#define COLOR |
- |
-#define FRAME_GRABBER_NUMBER 0 |
- |
-#define FG_PERIOD 40000 |
-#define FG_WCET 30000 |
-#define FG_W 320 |
-#define FG_H 240 |
- |
-void program_end(void *arg) |
-{ |
- |
- sys_end(); |
- |
-} |
- |
-void elaborate_image(void *imageptr); |
- |
-void start_frame_grabber(PID elaborate_task_PID, int channel, struct video_buffer *fbuf) { |
- |
- struct video_window win; |
- struct video_channel chan; |
- struct video_tuner tuner; |
- struct video_picture vpic; |
- int res; |
- |
- /* Init videodev driver */ |
- VIDEODEV26_open(FRAME_GRABBER_NUMBER); |
- |
- /* Select the input channel */ |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGCHAN,(unsigned long)&chan); |
- //cprintf("res = %d\n",res); |
- |
- chan.channel = channel; |
- chan.type = VIDEO_VC_TUNER; |
- chan.norm = VIDEO_TYPE_CAMERA; |
- |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSCHAN,(unsigned long)&chan); |
- //cprintf("res = %d\n",res); |
- |
- /* Enable the tuner */ |
- |
- tuner.tuner = 0; |
- tuner.mode = VIDEO_MODE_PAL; |
- |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSTUNER,(unsigned long)&tuner); |
- //cprintf("res = %d\n",res); |
- |
- /* Select palette and depth */ |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGPICT,(unsigned long)&vpic); |
- //cprintf("res = %d\n",res); |
- |
- #ifdef COLOR |
- vpic.palette = VIDEO_PALETTE_RGB24; |
- vpic.depth = 24; |
- #else |
- vpic.palette = VIDEO_PALETTE_GREY; |
- vpic.depth = 8; |
- #endif |
- |
- vpic.brightness = 35000; |
- vpic.hue = 32000; |
- vpic.contrast = 32000; |
- vpic.colour = 32000; |
- |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSPICT,(unsigned long)&vpic); |
- //cprintf("res = %d\n",res); |
- |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGWIN,(unsigned long)&win); |
- //cprintf("res = %d\n",res); |
- |
- win.x = 0; |
- win.y = 0; |
- win.width = FG_W; |
- win.height = FG_H; |
- |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSWIN,(unsigned long)&win); |
- //cprintf("res = %d\n",res); |
- |
- /* Set the buffer */ |
- res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSFBUF,(unsigned long)(fbuf)); |
- //cprintf("res = %d\n",res); |
- |
- /* IMPORTANT: Set the aperiodic elaboration task |
- * This is a SHARK change on VIDIOCSYNC. When the |
- * new frame is ready, the task elaborate_task_PID |
- * is activated. Elabortate_task must be aperiodic !! |
- * To link the task to BTTV use this function: */ |
- |
- VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSYNC,(unsigned long)(elaborate_task_PID)); |
- |
-} |
- |
-/* Check if the frame grabber is ready */ |
-volatile int ready_to_grab = 1; |
- |
-/* Elaboration task, it is called when the frame |
- grabber buffer is ready */ |
-TASK elaborate_task(void *arg) { |
- |
- struct video_buffer *fbuf = (struct video_buffer *)(arg); |
- |
- while(1) { |
- |
- elaborate_image(fbuf->base); |
- //cprintf("E"); |
- |
- //Text version |
- //printf_xy(1,20,WHITE,"%08x", |
- // *(unsigned int *)(fbuf->base+50*320*3+50*3)); |
- |
- ready_to_grab = 1; |
- |
- task_testcancel(); |
- task_endcycle(); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-/* Send the grab command */ |
-TASK grab_task(void *arg) { |
- |
- int on; |
- |
- while(1) { |
- |
- if (ready_to_grab) { |
- |
- task_nopreempt(); |
- |
- /* Grab */ |
- on = 1; |
- VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCCAPTURE,(unsigned long)&on); |
- |
- task_preempt(); |
- |
- //cprintf("G"); |
- |
- ready_to_grab = 0; |
- |
- } else { |
- |
- //cprintf("S"); |
- /* Frame skipped */ |
- |
- } |
- |
- task_testcancel(); |
- task_endcycle(); |
- |
- } |
- |
- return NULL; |
- |
-} |
- |
-extern void *video_memory; |
- |
-void elaborate_image(void *imageptr) |
-{ |
- |
- WORD x,y; |
- BYTE *col; |
- |
- #ifdef COLOR |
- |
- for(y = 0; y < FG_H; y++) |
- for(x = 0; x < FG_W; x++) { |
- |
- col = (BYTE *)(imageptr + y * FG_W * 3 + x * 3); |
- *(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col+2),*(BYTE *)(col+1),*(BYTE *)(col+0)); |
- |
- } |
- |
- #else |
- |
- for(y = 0; y < FG_H; y++) |
- for(x = 0; x < FG_W; x++) { |
- |
- col = (BYTE *)(imageptr + y * FG_W + x); |
- *(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col)); |
- |
- } |
- |
- #endif |
- |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- |
- HARD_TASK_MODEL gt; |
- SOFT_TASK_MODEL et; |
- PID grab_task_pid,elaborate_task_pid; |
- |
- struct video_buffer fbuf; |
- int channel = 0; |
- |
- if (argc < 2) { |
- sys_shutdown_message("ERROR: Enter the input channel [ex> %s 0]\n",argv[0]); |
- sys_end(); |
- } |
- |
- channel = atoi(argv[1]); |
- |
- soft_task_default_model(et); |
- soft_task_def_period(et,40000); |
- soft_task_def_arg(et,(void *)(&fbuf)); |
- soft_task_def_met(et,20000); |
- soft_task_def_aperiodic(et); |
- soft_task_def_ctrl_jet(et); |
- |
- hard_task_default_model(gt); |
- hard_task_def_mit(gt,40000); |
- hard_task_def_wcet(gt,5000); |
- hard_task_def_ctrl_jet(gt); |
- |
- grab_task_pid = task_create("GrabTask",grab_task,>,NULL); |
- if (grab_task_pid == NIL) { |
- sys_shutdown_message("ERROR: Cannot create grab task\n"); |
- sys_end(); |
- } |
- |
- elaborate_task_pid = task_create("ElaborateTask",elaborate_task,&et,NULL); |
- if (grab_task_pid == NIL) { |
- sys_shutdown_message("ERROR: Cannot create elaborate task\n"); |
- sys_end(); |
- } |
- |
- #ifdef COLOR |
- |
- fbuf.base = malloc(FG_W*FG_H*3); |
- fbuf.height = FG_H; |
- fbuf.width = FG_W; |
- fbuf.bytesperline = FG_W*3; |
- fbuf.depth = 24; |
- |
- #else |
- |
- fbuf.base = malloc(FG_W*FG_H); |
- fbuf.height = FG_H; |
- fbuf.width = FG_W; |
- fbuf.bytesperline = FG_W; |
- fbuf.depth = 8; |
- |
- #endif |
- |
- start_frame_grabber(elaborate_task_pid,channel,&fbuf); |
- |
- /* Activate periodic grabbing */ |
- task_activate(grab_task_pid); |
- |
- while(keyb_getch(BLOCK) != ESC); |
- |
- task_kill(grab_task_pid); |
- |
- sleep(1); |
- |
- sys_end(); |
- |
- return 0; |
- |
-} |
Index: tags/rel_1_4_rc1/bca/bca.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/bca.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/bca.c (nonexistent) |
@@ -1,203 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: bca.c,v 1.5 2004-05-23 08:59:27 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: bca.c * |
- * header file: bca.h * |
- * data: 15/09/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- ****************************************************** |
- * * |
- * descrizione: e' il file in cui è descritto il task* |
- * main del programma S.Ha.R.K. * |
- * "(B)ase(C)ontr(A)rea". * |
- * Il codice del programma comprende * |
- * anche l'implementazione di altri task* |
- * distribuiti nei seguenti file che * |
- * quindi sono inclusi: * |
- * dummy.c * |
- * control.c * |
- * aereo.c * |
- * cannone.c * |
- * missile.c * |
- * esplo.c * |
- * Inoltre è incluso anche il file: * |
- * scenario.c * |
- * che descrive come disegnare lo * |
- * scenario grafico iniziale * |
- * * |
- ******************************************************/ |
- |
- |
-// *** Librerie S.Ha.R.K *** |
-#include <kernel/kern.h> |
-#include <ll/i386/cons.h> |
- |
-#include <drivers/shark_fb26.h> |
-#include <drivers/shark_keyb26.h> |
- |
-// *** Librerie Standard C *** |
-#include <stdlib.h> |
-// *** Librerie FAB *** |
-#include "fab_lib/fab_msg.h" |
-#include "fab_lib/fab_show.h" |
-#include "fab_lib/fab_tool.h" |
-#include "fab_lib/fab_grx.h" |
-// *** Librerie BCA *** |
-#include "bca.h" |
- |
- |
-char * titolo[10]; |
- |
-void scenario(); |
-void info(); |
-#include"scenario.c" |
- |
-PID crea_soft_dummy_radar (); |
-TASK dummy_radar(void *); |
-#include"dummy.c" |
- |
-PID crea_soft_control(); |
-TASK control(void *); |
-#include"control.c" |
- |
-PID crea_soft_aereo_creator(); |
-TASK aereo_creator(); |
-PID crea_hard_aereo(int index); |
-PID crea_soft_aereo(int index); |
-TASK aereo(void * index); |
-#include"aereo.c" |
- |
-PID crea_soft_cannone_creator(); |
-TASK cannone_creator(); |
-PID crea_hard_cannone(int index); |
-PID crea_soft_cannone(int index); |
-TASK cannone(void * index); |
-#include"cannone.c" |
- |
-PID crea_hard_missile(); |
-PID crea_soft_missile(); |
-TASK missile(); |
-#include"missile.c" |
- |
-PID crea_soft_esplo(); |
-TASK esplo(void *); |
-#include"esplo.c" |
- |
-void end_fun(KEY_EVT* k) |
-{ sys_shutdown_message("Ending...\n"); |
- sys_end(); |
-} |
-void incrementa_aerei_fun(KEY_EVT* k) |
-{ if (aereo_count<AEREO_N_MAX) aereo_count++; |
-} |
-void decrementa_aerei_fun(KEY_EVT* k) |
-{ if (aereo_count>AEREO_N_MIN) aereo_count--; |
-} |
-void incrementa_cannoni_fun(KEY_EVT* k) |
-{ if (cannone_count<CANNONE_N_MAX) cannone_count++; |
-} |
-void decrementa_cannoni_fun(KEY_EVT* k) |
-{ if (cannone_count>CANNONE_N_MIN) cannone_count--; |
-} |
- |
-int main(int argc, char **argv) |
-{ |
- PID pid; |
- |
- KEY_EVT k; |
- |
- k.flag = 0; |
- k.scan = KEY_ENT; |
- k.ascii = 13; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,end_fun,FALSE); |
- k.flag = 0; |
- k.scan = KEY_1; |
- k.ascii = '1'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,incrementa_aerei_fun,FALSE); |
- k.flag = 0; |
- k.scan = KEY_2; |
- k.ascii = '2'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,decrementa_aerei_fun,FALSE); |
- k.flag = 0; |
- k.scan = KEY_3; |
- k.ascii = '3'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,incrementa_cannoni_fun,FALSE); |
- k.flag = 0; |
- k.scan = KEY_4; |
- k.ascii = '4'; |
- k.status = KEY_PRESSED; |
- keyb_hook(k,decrementa_cannoni_fun,FALSE); |
- |
- /* inizializza il mutex grafico */ |
- app_mutex_init(&grx_mutex); |
- |
- scenario(); |
- |
- //---init--- |
- srand(sys_gettime(NULL)); |
- aereo_count = AEREO_N_MIN; |
- cannone_count = CANNONE_N_MIN; |
- |
- pid=crea_soft_dummy_radar(); |
- task_activate(pid); |
- |
- pid=crea_soft_aereo_creator(); |
- task_activate(pid); |
- |
- pid=crea_soft_cannone_creator(); |
- task_activate(pid); |
- |
- pid=crea_soft_control(); |
- task_activate(pid); |
- //---------- |
- |
- return 0; |
- |
-} |
- |
- |
Index: tags/rel_1_4_rc1/bca/bca.h |
=================================================================== |
--- tags/rel_1_4_rc1/bca/bca.h (revision 1476) |
+++ tags/rel_1_4_rc1/bca/bca.h (nonexistent) |
@@ -1,288 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: bca.h,v 1.2 2002-10-01 10:33:51 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: bca.h * |
- * included by: bca.c & bca_lib di cui fa da header* |
- * data: 15/09/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- ****************************************************** |
- * * |
- * descrizione: contiene la definizione di variabili * |
- * e strutture globali, con un corredo * |
- * di macro e funzioni per la loro * |
- * gestione, usate nel programma SHaRK * |
- * "(B)ase(C)ontr(A)rea", il cui codice * |
- * e' scritto nel file bca.c; * |
- * il file bca_lib.c contiene il corpo * |
- * di tutte le funzioni qui dichiarate. * |
- * * |
- ******************************************************/ |
- |
-#ifndef __BCA_H__ |
-#define __BCA_H__ |
-//----------------BEGIN------------------ |
- |
-// *** Librerie S.Ha.R.K *** |
-// *** Librerie Standard C *** |
-// *** Librerie FAB *** |
-#include"fab_lib/fab_grx.h" |
-#include"fab_lib/fab_tool.h" |
-// *** Librerie BCA *** |
- |
- |
-// --------------------------------- |
-// *** Elementi Grafici Generici *** |
-// --------------------------------- |
- |
-// IMMAGINI: |
-FAB_IMAGE* image_sfondo; |
-FAB_IMAGE* image_bca; |
-FAB_IMAGE* image_aereo[4]; // 1 aereo per ogni direzione(soft e hard) |
-FAB_IMAGE* image_esplo[5]; // 5 immagini in sequenza simulanti |
-FAB_IMAGE* image_cannone[2]; // un esplosione |
-FAB_IMAGE* image_missile[2]; |
- |
-// BORDI: |
-FAB_BORDER* border_blu7; |
-FAB_BORDER* border_verde7; |
-FAB_BORDER* border_rosso7; |
-FAB_BORDER* border_bianco7; |
-FAB_BORDER* border_giallo7; |
- |
-// FRAME: |
-FAB_FRAME* frame_bca; |
-FAB_FRAME* frame_misure_oriz; |
-FAB_FRAME* frame_misure_vert; |
-FAB_FRAME* frame_misure_vert; |
-FAB_FRAME* frame_titolo; |
-FAB_FRAME* frame_comandi; |
-FAB_FRAME* frame_control; |
- |
-// BALLFRAME: |
-FAB_BALLFRAME* ballframe_radar; |
-FAB_BALLFRAME* ballframe_lucerossa[3]; |
- |
-// Base ContrAerea |
-#define BASE_L 1.0 // [Km]: lunghezza |
-#define BASE_H 2100 // [m]: altezza max di visibilita' |
- |
-// Finestra Virtuale sullo schermo |
-#define FIN_X_MIN 20 // [pixel] |
-#define FIN_X_MAX 520-1 // [pixel] |
-#define FIN_Y_MIN 20 // [pixel] |
-#define FIN_Y_MAX 520-1 // [pixel] |
-// Inoltre si possono usare le seguenti + comode define |
-// con gli stessi valori: |
-#define X0 FIN_X_MIN |
-#define X1 FIN_X_MAX |
-#define Y0 FIN_Y_MIN |
-#define Y1 FIN_Y_MAX |
-// NB: non e' necessaria la proporzionalita' tra finestra |
-// reale(BASE_L*BASE_H) e virtuale((X1-X0)*(Y1-Y0))! |
- |
-// Finestra Misure |
-#define FRAME_MISURE_LINE_COLOR FAB_green |
-#define FRAME_MISURE_BACK_COLOR FAB_black |
-#define FRAME_MISURE_ORIZ_LY 30 |
-#define FRAME_MISURE_VERT_LX 52 |
- |
-// Finestra Titolo |
-#define FRAME_TITOLO_TEXT_COLOR1 FAB_yellow |
-#define FRAME_TITOLO_TEXT_COLOR2 FAB_white |
-#define FRAME_TITOLO_BACK_COLOR1 FAB_gray |
-#define FRAME_TITOLO_BACK_COLOR2 FAB_blue |
- |
-// Finestra Comandi |
-#define FRAME_COMANDI_TEXT_COLOR1 FAB_yellow |
-#define FRAME_COMANDI_TEXT_COLOR2 FAB_white |
-#define FRAME_COMANDI_TEXT_COLOR3 FAB_red |
-#define FRAME_COMANDI_BACK_COLOR1 FAB_gray |
-#define FRAME_COMANDI_BACK_COLOR2 FAB_yellow |
- |
-// Finestra Control |
-#define FRAME_CONTROL_TEXT_COLOR1 FAB_rgb( 50,255, 50) |
-#define FRAME_CONTROL_TEXT_COLOR2 FAB_rgb(150,255,150) |
-#define FRAME_CONTROL_BACK_COLOR FAB_black |
- |
-// --------------------------------- |
-// *** Elementi Task Dummy_radar *** |
-// --------------------------------- |
-#define DUMMY_RADAR_GROUP 3 |
-#define DUMMY_RADAR_PERIOD 50000 |
-#define DUMMY_RADAR_WCET 400 |
-#define DUMMY_RADAR_MET 200 |
- |
-// --------------------------------- |
-// *** Elementi Task Control *** |
-// --------------------------------- |
-#define CONTROL_PERIOD 50000 |
-#define CONTROL_WCET 400 |
-#define CONTROL_MET 300 |
- |
-// --------------------------- |
-// *** Elementi Task Esplo *** |
-// --------------------------- |
-#define ESPLO_TRASPARENT_COL FAB_white |
-#define ESPLO_LX 40 |
-#define ESPLO_LY 40 |
- |
-#define ESPLO_PERIOD 80000 |
-#define ESPLO_WCET 300 |
-#define ESPLO_MET 100 |
- |
-// ----------------------------------- |
-// *** Elementi Task Aereo_Creator *** |
-// ----------------------------------- |
-#define AEREO_CREATOR_PERIOD 200000 |
-#define AEREO_CREATOR_WCET 300 |
-#define AEREO_CREATOR_MET 100 |
- |
-// ----------------------------------- |
-// *** Elementi Task Cannone_Creator *** |
-// ----------------------------------- |
-#define CANNONE_CREATOR_PERIOD 1000000 |
-#define CANNONE_CREATOR_WCET 150 |
-#define CANNONE_CREATOR_MET 50 |
- |
-// --------------------------- |
-// *** Elementi Task Aereo *** |
-// --------------------------- |
-#define AEREO_N_MAX 10 |
-#define AEREO_N_MIN 1 |
- |
-#define AEREO_TRASPARENT_COL FAB_white |
-#define AEREO_BASE_COL FAB_green |
-#define AEREO_LX 32 |
-#define AEREO_LY 19 |
-#define AEREO_H_MIN 500 // [m]: altezza min di volo |
-#define AEREO_H_MAX 2000 // [m]: altezza max di volo (<BASE_H) |
-#define AEREO_L_MIN 0 // [km]: posizione 0 nella base |
-#define AEREO_L_MAX BASE_L // [km] posizione max nella base |
-#define AEREO_V_MIN 300.0 // [Km/h]: velocit
min di volo |
-#define AEREO_V_MAX 500.0 // [Km/h]: velocit
max di volo |
-#define AEREO_X_MIN X0 - AEREO_LX/2 |
-#define AEREO_X_MAX X1 + AEREO_LX/2 |
- |
-#define AEREO_PERIOD 30000 |
-#define AEREO_WCET 1250 //Verificato! |
-#define AEREO_MET 800 |
- |
-struct { BYTE status; //[0=free/1=occupato] |
- BYTE killing; //richiesta uscita se 1 altrimenti 0 |
- PID pid; |
- COLOR color; |
- FAB_IMAGE* image; |
- double vel; //[km/h] |
- int dir; //[+1/-1] |
- WORD h; //[m] |
- double l; //[km] |
- WORD x, y; //[pixel] |
- } aereo_table[AEREO_N_MAX]; |
- |
-int aereo_count; |
- |
-// ----------------------------- |
-// *** Elementi Task Cannone *** |
-// ----------------------------- |
-#define CANNONE_N_MAX 9 |
-#define CANNONE_N_MIN 1 |
- |
-#define CANNONE_SENSIBILITA 200 //[m] |
- |
-#define CANNONE_TRASPARENT_COL FAB_white |
-#define CANNONE_LX 33 |
-#define CANNONE_LY 15 |
- |
-#define CANNONE_PERIOD 100000 |
-#define CANNONE_WCET 1000 |
-#define CANNONE_MET 100 |
- |
-struct { BYTE status; //[0=free/1=occupato] |
- BYTE killing; //richiesta uscita se 1 altrimenti 0 |
- PID pid; |
- BYTE fire; |
- WORD x; |
- double missile_vel; |
- } cannone_table[CANNONE_N_MAX]; |
- |
-int cannone_count; |
- |
-// ----------------------------- |
-// *** Elementi Task Missile *** |
-// ----------------------------- |
-#define MISSILE_V_MIN 300.0 //[km/h] |
-#define MISSILE_V_MAX 5000.0 //[km/h] |
-#define MISSILE_ACC_MIN 100000.0 //[km/(h*h)] |
-#define MISSILE_ACC_MAX 10000000.0 //[km/(h*h)] |
-#define MISSILE_X_MAX X1 + MISSILE_LX/2 //[pixel] |
-#define MISSILE_X_MIN X0 - MISSILE_LX/2 //[pixel] |
-#define MISSILE_Y_MAX Y1 + MISSILE_LY/2 //[pixel] |
-#define MISSILE_Y_MIN Y0 - MISSILE_LY/2 //[pixel] |
- |
-#define MISSILE_TRASPARENT_COL FAB_white |
- |
-#define MISSILE_LX 7 //[pixel] |
-#define MISSILE_LY 15 //[pixel] |
- |
-#define MISSILE_PERIOD 10000 |
-#define MISSILE_WCET 500 |
-#define MISSILE_MET 100 |
- |
- |
- |
- |
- |
-// MUTEX: |
-mutex_t grx_mutex; //per l'accesso alla grafica |
-int app_mutex_init(mutex_t *m); |
- |
- |
- |
-// FUNZIONI GESTIONE RISORSE DI MEMORIA: |
-void kern_init_bca(); |
- |
- |
- |
-//------------------END------------------ |
-#endif |
Index: tags/rel_1_4_rc1/bca/aereo.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/aereo.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/aereo.c (nonexistent) |
@@ -1,241 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: aereo.c,v 1.2 2004-05-25 18:24:59 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-//************************ |
-//* file: aereo.c * |
-//* included by: bca.c * |
-//************************ |
- |
-TASK aereo_creator(void * arg) |
-{ int i, index, last; |
- WORD count; |
- PID pid=-1; |
- COLOR col; |
- double vel; |
- int dir; |
- WORD h; |
- double l; |
- WORD x, y; |
- |
- while(1){ |
- |
- count=0; |
- index=-1; |
- last=-1; |
- |
- for (i=0; i<AEREO_N_MAX; i++) // Conteggio aerei attivi |
- if (aereo_table[i].status) { |
- count++; |
- last=i; //...ultima posizione occupata in tabella... |
- } |
- else { |
- if (index==-1) index=i; //...prima posizione libera in tabella... |
- } |
- |
- if (count<aereo_count && index!=-1) { // Richiesta nuovo aereo |
- aereo_table[index].status = 1; //...occupa posizione... |
- aereo_table[index].killing = 0; //...disattiva richiesta di kill... |
- col = FAB_rgb(FAB_int_rand(50,255), //...nuovo colore... |
- FAB_int_rand(50,255), |
- FAB_int_rand(50,255)); |
- vel = FAB_double_rand(AEREO_V_MIN,AEREO_V_MAX); //...velocita'... |
- dir = FAB_sign_rand(); //...direzione... |
- h = FAB_int_rand(AEREO_H_MIN,AEREO_H_MAX); //...altezza... |
- y = Y0 + 500 - h*500/BASE_H; |
- l = (dir>0) ? AEREO_L_MIN : AEREO_L_MAX; //...posizione iniz... |
- x = (dir>0) ? AEREO_X_MIN : AEREO_X_MAX; |
- // ... settaggio valori in tabella ... |
- aereo_table[index].color = col; |
- if (index>0) { |
- if (dir>0) FAB_image_copy(image_aereo[0],aereo_table[index].image); |
- else FAB_image_copy(image_aereo[1],aereo_table[index].image); |
- } |
- else { |
- if (dir>0) FAB_image_copy(image_aereo[2],aereo_table[index].image); |
- else FAB_image_copy(image_aereo[3],aereo_table[index].image); |
- } |
- FAB_image_color_change(aereo_table[index].image,AEREO_BASE_COL,col); |
- aereo_table[index].vel = vel; |
- aereo_table[index].dir = dir; |
- aereo_table[index].h = h; |
- aereo_table[index].l = l; |
- aereo_table[index].x = x; |
- aereo_table[index].y = y; |
- if (index==0) pid = crea_hard_aereo(index); // sempre il 1ø hard |
- else pid = crea_soft_aereo(index); // tutti gli altri soft |
- aereo_table[index].pid = pid; |
- if (pid!=NIL) task_activate(pid); |
- else { //ripristino il posto libero in tabella; |
- aereo_table[index].status = 0; |
- aereo_table[index].killing = 0; |
- } |
- } |
- |
- else if (count>aereo_count) { // Richiesta cancellazione aereo |
- aereo_table[last].killing = 1; |
- } |
- |
- task_endcycle(); |
- } |
- return NULL; |
-} |
- |
-TASK aereo(void *arg) |
-{ |
- int index; // indice nella aereo_table |
- FAB_IMAGE* image; |
- int xx0,yy0,xx1,yy1; |
- int y; |
- double x; |
- double old_x; // [pixel]: conserva valore x prima di aggiornare |
- double dx; // [pixel/us]: spostamento periodico |
- int first_time; |
- |
- index = (int)arg; |
- image = aereo_table[index].image; |
- y = aereo_table[index].y; |
- x = aereo_table[index].x; |
- dx = aereo_table[index].vel * (AEREO_X_MAX-AEREO_X_MIN) / (double)BASE_L |
- * (AEREO_PERIOD / (60*60*1000000.0)) |
- * aereo_table[index].dir; |
- first_time = 1; |
- |
- while(1){ |
- |
- old_x = x; |
- x += dx; |
- |
- xx0 = old_x - AEREO_LX/2; |
- yy0 = y - AEREO_LY/2; |
- xx1 = xx0 + AEREO_LX - 1; |
- yy1 = yy0 + AEREO_LY - 1; |
- |
- aereo_table[index].x = x; //...aggiornamento posizione in tabella... |
- |
- if (x<AEREO_X_MIN || x>AEREO_X_MAX) { |
- aereo_table[index].killing = 1; |
- } |
- |
- if (aereo_table[index].killing) { |
- if (!first_time) { |
- mutex_lock(&grx_mutex); |
- FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
- mutex_unlock(&grx_mutex); |
- } |
- aereo_table[index].status=0; |
- aereo_table[index].pid=-2; |
- aereo_table[index].killing=0; |
- //il task aereo_creator si accorge che c' un aereo in meno |
- // quindi ne ricreer
uno nuovo!!! |
- return NULL; |
- } |
- |
- if(aereo_table[index].x!=(int)old_x) {//...se c' lo spostamento reale |
- // di almeno un pixel... |
- mutex_lock(&grx_mutex); //...aggiorna disegno... |
- if (first_time) { |
- first_time=0; |
- } |
- else { |
- FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
- } |
- |
- FAB_image_put_within(image, x - AEREO_LX/2, y - AEREO_LY/2, |
- X0, Y0, X1, Y1); |
- mutex_unlock(&grx_mutex); |
- } |
- |
- task_endcycle(); |
- } |
- |
-return NULL; |
-} |
- |
-PID crea_soft_aereo_creator() |
-{ |
- SOFT_TASK_MODEL m; |
- PID pid; |
- |
- soft_task_default_model(m); |
- soft_task_def_periodic(m); |
- soft_task_def_period(m,AEREO_CREATOR_PERIOD); |
- soft_task_def_wcet(m,AEREO_CREATOR_WCET); |
- soft_task_def_met(m,AEREO_CREATOR_MET); |
- |
- pid = task_create("aereo_creator", aereo_creator, &m, NULL); |
- return pid; |
-} |
- |
-PID crea_hard_aereo(int index) |
-{ |
- HARD_TASK_MODEL m; |
- PID pid; |
- |
- hard_task_default_model(m); |
- hard_task_def_level(m,1); |
- hard_task_def_arg(m,(void*)index); |
- hard_task_def_periodic(m); |
- hard_task_def_wcet(m, AEREO_WCET); |
- hard_task_def_mit(m,AEREO_PERIOD); |
- hard_task_def_usemath(m); |
- |
- pid = task_create("hard_aereo", aereo, &m, NULL); |
- return pid; |
-} |
- |
-PID crea_soft_aereo(int index) |
-{ |
- SOFT_TASK_MODEL m; |
- PID pid; |
- |
- soft_task_default_model(m); |
- soft_task_def_level(m,2); |
- soft_task_def_arg(m,(void*)index); |
- soft_task_def_periodic(m); |
- soft_task_def_period(m,AEREO_PERIOD); |
- soft_task_def_wcet(m, AEREO_WCET); |
- soft_task_def_met(m,AEREO_MET); |
- soft_task_def_usemath(m); |
- |
- pid = task_create("soft aereo", aereo, &m, NULL); |
- return pid; |
-} |
- |
Index: tags/rel_1_4_rc1/bca/dummy.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/dummy.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/dummy.c (nonexistent) |
@@ -1,107 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: dummy.c,v 1.1 2002-10-01 10:25:00 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-//************************ |
-//* file: dummy.c * |
-//* included by: bca.c * |
-//************************ |
- |
-PID crea_soft_dummy_radar() |
-{ |
- SOFT_TASK_MODEL m; |
- PID pid; |
- |
- soft_task_default_model(m); |
- soft_task_def_level(m,0); |
- soft_task_def_periodic(m); |
- soft_task_def_period(m,DUMMY_RADAR_PERIOD); |
- soft_task_def_wcet(m,DUMMY_RADAR_WCET); |
- soft_task_def_met(m,DUMMY_RADAR_MET); |
- |
- pid = task_create("dummy_radar", dummy_radar, &m, NULL); |
- return pid; |
-} |
- |
-TASK dummy_radar(void *argv) |
-{ |
- WORD i,r,r_max,pos; |
- BYTE red[3]={250, 150,50}; |
- int d[3]= {+10,+10,+10}; |
- |
- r = 0; |
- r_max = ballframe_radar->r+1; |
- |
- while(1){ |
- for(i=0; i<3; i++) { |
- if (red[i]<50) d[i]=+10; |
- if (red[i]>250) d[i]=-50; |
- red[i] += d[i]; |
- grx_disc(ballframe_lucerossa[i]->cx, |
- ballframe_lucerossa[i]->cy, |
- ballframe_lucerossa[i]->r, |
- FAB_rgb(red[i],50,50)); |
- } |
- grx_disc(ballframe_radar->cx, |
- ballframe_radar->cy, |
- r_max, FAB_blue); |
- grx_circle(ballframe_radar->cx, |
- ballframe_radar->cy, |
- (r+9)%r_max, FAB_white); |
- grx_circle(ballframe_radar->cx, |
- ballframe_radar->cy, |
- (r+5)%r_max, FAB_rgb(200,200,255)); |
- grx_circle(ballframe_radar->cx, |
- ballframe_radar->cy, |
- r%r_max, FAB_rgb(100,100,255)); |
- for (i=0; i<AEREO_N_MAX; i++) { |
- if (aereo_table[i].status |
- &&aereo_table[i].x>X0 |
- &&aereo_table[i].y>Y0) { |
- pos = ballframe_radar->cx - ballframe_radar->r |
- + (aereo_table[i].x-X0)*2*ballframe_radar->r/500; |
- grx_plot(pos,ballframe_radar->cy,FAB_yellow); |
- } |
- } |
- r++; |
- |
- task_endcycle(); |
- } |
-} |
Index: tags/rel_1_4_rc1/bca/makefile |
=================================================================== |
--- tags/rel_1_4_rc1/bca/makefile (revision 1476) |
+++ tags/rel_1_4_rc1/bca/makefile (nonexistent) |
@@ -1,16 +0,0 @@ |
-# |
-# |
-# |
- |
-ifndef BASE |
-BASE=../.. |
-endif |
-include $(BASE)/config/config.mk |
- |
-PROGS= bca |
- |
-include $(BASE)/config/example.mk |
- |
-bca: |
- make -f $(SUBMAKE) APP=bca INIT= OTHEROBJS="initfile.o fab_lib.o bca_lib.o" SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __FB__" |
- |
Index: tags/rel_1_4_rc1/bca/fab_lib/fab_grx.h |
=================================================================== |
--- tags/rel_1_4_rc1/bca/fab_lib/fab_grx.h (revision 1476) |
+++ tags/rel_1_4_rc1/bca/fab_lib/fab_grx.h (nonexistent) |
@@ -1,203 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: fab_grx.h,v 1.3 2004-05-23 08:59:28 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: FAB_grx.h * |
- * libreria: FAB_LIB * |
- * version: 1.0 25/08/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- **************************************************** |
- * * |
- * descrizione: libreria di funzioni grafiche: * |
- * permette di gestire con facilita' * |
- * immagini, cornici, e veri e propri * |
- * pannelli colorati. * |
- * Il contesto di grafica va avviato * |
- * con FAB_grx_open() e alla fine * |
- * chiuso correttamente con la funz. * |
- * FAB_grx_close(). L'ambiente di * |
- * grafica e'impostato a 16bit per * |
- * default, comunque e' sempre * |
- * possibile scegliere la profondita' * |
- * di colori preferita tra 15/16/24/32* |
- * definendo semplicemente solo una * |
- * delle seguenti costanti all'inizio * |
- * del proprio programma che include * |
- * questa libreria grafica: * |
- * FAB_GRX_15 * |
- * FAB_GRX_16 (default) * |
- * FAB_GRX_24 * |
- * FAB_GRX_32 * |
- * * |
- ****************************************************/ |
- |
-#ifndef __FAB_LIB_fab_grx_h__ |
-#define __FAB_LIB_fab_grx_h__ |
-//-------------------BEGIN--------------------------- |
- |
-// *** Librerie di S.Ha.R.K. *** |
-#include <kernel/kern.h> |
-#include <ll/sys/types.h> |
- |
-#include <drivers/shark_fb26.h> |
- |
-// *** Librerie Standard C *** |
-// *** Librerie FAB *** |
-#include"fab_grx.sys" |
- |
-//#define FAB_GRX_15 |
-//#define FAB_GRX_16 |
-//#define FAB_GRX_24 |
-//#define FAB_GRX_32 |
- |
-typedef __FAB_COLOR COLOR; |
- |
-typedef struct { |
- WORD lx,ly; |
- COLOR * buf; |
- int trasparent; |
- COLOR trasparent_col; |
- } FAB_IMAGE; |
- |
-typedef struct { |
- WORD dim; |
- COLOR * buf; |
- } FAB_BORDER; |
- |
-typedef struct { |
- FAB_BORDER * border; //default = NULL |
- WORD border_dim; //default = 0 |
- COLOR border_col; |
- |
- BYTE trasparent; //default = 0 |
- FAB_IMAGE * image; //default = NULL |
- COLOR color; |
- |
- WORD x0,y0,x1,y1; //spigoli pannello interno |
- //cornice esclusa: vengono settati |
- //automaticamente con FAB_frame_put(). |
- } FAB_FRAME; |
-typedef struct { |
- FAB_BORDER * border; //default = NULL |
- WORD border_dim; //default = 0 |
- COLOR border_col; |
- |
- BYTE trasparent; //default = 0 |
- COLOR color; |
- |
- WORD cx,cy,r; //centro e raggio del pannello |
- //circolare: vengono settati |
- //automaticamente con FAB_ballframe_put(). |
- } FAB_BALLFRAME; |
- |
-// ----------- |
-// Definizioni |
-//---------------------- |
-#define FAB_BPP __FAB_BPP |
-#define FAB_rgb(R24,G24,B24) __FAB_rgb((R24),(G24),(B24)) |
- |
-// Colori base |
-#define FAB_white FAB_rgb(255,255,255) |
-#define FAB_black FAB_rgb( 0, 0, 0) |
-#define FAB_red FAB_rgb(255, 0, 0) |
-#define FAB_green FAB_rgb( 0,255, 0) |
-#define FAB_blue FAB_rgb( 0, 0,255) |
-#define FAB_yellow FAB_rgb(255,255, 0) |
-#define FAB_gray FAB_rgb(100,100,100) |
- |
-//---------------------- |
- |
-// ---------------- |
-// Funzioni & Macro |
-//-------------------------------------------------- |
-int FAB_grx_open(WORD lx, WORD ly); |
-void FAB_grx_close(); |
- |
-FAB_IMAGE* FAB_image_alloc(WORD lx, WORD ly); //richiede DISABLED INTERRUPTS |
-void FAB_image_free(FAB_IMAGE* image); //richiede DISABLED INTERRUPTS |
-FAB_BORDER* FAB_border_alloc(WORD dim); //richiede DISABLED INTERRUPTS |
-void FAB_border_free(FAB_BORDER * border);//richiede DISABLED INTERRUPTS |
-FAB_FRAME* FAB_frame_alloc(); //richiede DISABLED INTERRUPTS |
-void FAB_frame_free(FAB_FRAME * frame); //richiede DISABLED INTERRUPTS |
-FAB_BALLFRAME* FAB_ballframe_alloc(); //richiede DISABLED INTERRUPTS |
-void FAB_ballframe_free(FAB_BALLFRAME * frame);//richiede DISABLED INTERRUPTS |
- |
-// Permette di riempire lo spazio allocato ad un FAB_IMAGE |
-// leggendo le sequenze rgb a 24bit da un file immagine binario. |
-// Un formato perfettamente compatibile quello |
-// "RAW"(con header=0 e sequenza ad ordinamento RGB-RGB-RGB...): |
-int FAB_image_load(FAB_IMAGE* image, char* file_name); // solo in __kernel_register_levels__() |
-// Per default un FAB_IMAGE non ha il colore di trasparenza: |
-#define FAB_image_no_trasparent_set(IMAGE) (IMAGE)->trasparent=0 |
-#define FAB_image_trasparent_set(IMAGE,TRASPARENT_COL) (IMAGE)->trasparent=1;(IMAGE)->trasparent_col=(TRASPARENT_COL) |
- |
-// Settaggio FAB_BORDER deve essere fatto manualmente! |
-// esempio: |
-// mio_border->buf[i] = FAB_rgb(0,100,0); |
-// ... |
-// mio_border->buf[N] = FAB_rgb(0,100,255); |
-// (non esiste una funzione FAB_border_set) |
- |
-#define FAB_frame_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
-#define FAB_frame_color_set(FRAME,TRASPARENT_FLAG,IMAGE,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->image=(IMAGE);(FRAME)->color=(COLOR); |
-#define FAB_ballframe_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
-#define FAB_ballframe_color_set(FRAME,TRASPARENT_FLAG,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->color=(COLOR); |
- |
-void FAB_ball_put(WORD cx, WORD cy, WORD r, COLOR c); |
-void FAB_image_get(FAB_IMAGE* image, WORD x, WORD y, WORD lx, WORD ly); |
-void FAB_image_put(FAB_IMAGE* image, WORD x, WORD y); |
-void FAB_image_put_within(FAB_IMAGE* image, WORD x0, WORD y0, |
- WORD xx0, WORD yy0, WORD xx1, WORD yy1); |
-void FAB_image_copy(FAB_IMAGE* orig_image, FAB_IMAGE* dest_image); |
-void FAB_image_color_change(FAB_IMAGE* image, COLOR old_col, COLOR new_col); |
-void FAB_image_fill(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly); |
-void FAB_border_put(FAB_BORDER* border, WORD x0, WORD y0, WORD x1, WORD y1); |
-void FAB_ballborder_put(FAB_BORDER* border, WORD cx, WORD cy, WORD r_int); |
-void FAB_frame_put(FAB_FRAME* frame, WORD x0, WORD y0, WORD lx, WORD ly); |
-void FAB_ballframe_put(FAB_BALLFRAME* frame, WORD cx, WORD cy, WORD r); |
-//-------------------------------------------------- |
- |
-// Altro... |
- |
-//---------------------END--------------------------- |
-#endif |
Index: tags/rel_1_4_rc1/bca/fab_lib/fab_show.h |
=================================================================== |
--- tags/rel_1_4_rc1/bca/fab_lib/fab_show.h (revision 1476) |
+++ tags/rel_1_4_rc1/bca/fab_lib/fab_show.h (nonexistent) |
@@ -1,83 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: fab_show.h,v 1.2 2002-10-01 10:33:52 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: FAB_show.h * |
- * libreria: FAB_LIB * |
- * version: 1.0 25/08/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- **************************************************** |
- * * |
- * descrizione: libreria di funzioni per stampare * |
- * specifiche informazioni utili * |
- * riguardo lo stato del sistema. * |
- * * |
- ****************************************************/ |
- |
-#ifndef __FAB_LIB__FAB_show_h__ |
-#define __FAB_LIB__FAB_show_h__ |
-//-------------------BEGIN--------------------------- |
- |
-// *** Librerie S.Ha.R.K *** |
- |
-// *** Librerie Standard C *** |
- |
-// *** Librerie FAB *** |
-#include "fab_msg.h" |
- |
-// ----------- |
-// Definizioni |
-//---------------------- |
-//---------------------- |
- |
-// ---------------- |
-// Funzioni & Macro |
-//------------------------------------------------- |
-void FAB_show_sched_modules(); |
-//-------------------------------------------------- |
- |
- |
-// Altro... |
- |
-//----------------------END-------------------------- |
-#endif |
Index: tags/rel_1_4_rc1/bca/fab_lib/fab_msg.h |
=================================================================== |
--- tags/rel_1_4_rc1/bca/fab_lib/fab_msg.h (revision 1476) |
+++ tags/rel_1_4_rc1/bca/fab_lib/fab_msg.h (nonexistent) |
@@ -1,94 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: fab_msg.h,v 1.2 2004-05-23 08:59:28 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: FAB_msg.h * |
- * libreria: FAB_LIB * |
- * version: 1.0 25/08/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- **************************************************** |
- * * |
- * descrizione: libreria di funzioni per stampare * |
- * messaggi circa il corretto esito * |
- * dell'esecuzione delle istruzioni; * |
- * stampa semplici stringhe colorate; * |
- * aiuta a fare il debbuging. * |
- * * |
- ****************************************************/ |
- |
-#ifndef __FAB_LIB__FAB_msg_h__ |
-#define __FAB_LIB__FAB_msg_h__ |
-//-------------------BEGIN--------------------------- |
- |
-// *** Librerie di S.Ha.R.K. *** |
-#include <ll/i386/cons.h> |
-// *** Librerie Standard C *** |
-// *** Librerie FAB *** |
- |
-// ----------- |
-// Definizioni |
-//---------------------- |
-#define FAB_EXIT_YES 1 |
-#define FAB_EXIT_NO 0 |
-#define FAB_EMPTY_MSG "" |
-//---------------------- |
- |
-// ---------------- |
-// Funzioni & Macro |
-//------------------------------------------------- |
-#define FAB_newline() NL() |
-#define FAB_home() HOME() |
-#define FAB_clr() clear() |
- |
-void FAB_print(char * InitMsg, char * msg); |
-#define FAB_msg(TEST,OKMSG,ERRORMSG) __FAB_go((TEST),(OKMSG),(ERRORMSG),FAB_EXIT_NO) |
-#define FAB_go(TEST,OKMSG,ERRORMSG,EXITFLAG) __FAB_go((TEST),(OKMSG),(ERRORMSG),(EXITFLAG)) |
-//-------------------------------------------------- |
- |
- |
-// Altro... |
- |
-void __FAB_go(int test, char * OkMsg, char * ErrorMsg,int EXITflag); |
- |
-//----------------------END-------------------------- |
-#endif |
Index: tags/rel_1_4_rc1/bca/fab_lib/fab_grx.sys |
=================================================================== |
--- tags/rel_1_4_rc1/bca/fab_lib/fab_grx.sys (revision 1476) |
+++ tags/rel_1_4_rc1/bca/fab_lib/fab_grx.sys (nonexistent) |
@@ -1,71 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: fab_grx.sys,v 1.1 2002-10-01 10:25:02 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-// file incluso da FAB_grx.h |
-// ------------------------- |
- |
-typedef BYTE COLOR8; |
-typedef WORD COLOR15; |
-typedef WORD COLOR16; |
-typedef DWORD COLOR24; |
-typedef DWORD COLOR32; |
- |
-#if defined FAB_GRX_15 |
- #define __FAB_BPP 15 |
- #define __FAB_rgb(R24,G24,B24) rgb15((R24),(G24),(B24)) |
- typedef COLOR15 __FAB_COLOR; |
-#elif defined FAB_GRX_16 |
- #define __FAB_BPP 16 |
- #define __FAB_rgb(R24,G24,B24) rgb16((R24),(G24),(B24)) |
- typedef COLOR16 __FAB_COLOR; |
-#elif defined FAB_GRX_24 |
- #define __FAB_BPP 24 |
- #define __FAB_rgb(R24,G24,B24) rgb24((R24),(G24),(B24)) |
- typedef COLOR24 __FAB_COLOR; |
-#elif defined FAB_GRX_32 |
- #define __FAB_BPP 32 |
- #define __FAB_rgb(R24,G24,B24) rgb32((R24),(G24),(B24)) |
- typedef COLOR32 __FAB_COLOR; |
-#else |
- #define __FAB_BPP 16 |
- #define __FAB_rgb(R24,G24,B24) rgb16((R24),(G24),(B24)) |
- typedef COLOR16 __FAB_COLOR; |
-#endif |
Index: tags/rel_1_4_rc1/bca/fab_lib/fab_tool.h |
=================================================================== |
--- tags/rel_1_4_rc1/bca/fab_lib/fab_tool.h (revision 1476) |
+++ tags/rel_1_4_rc1/bca/fab_lib/fab_tool.h (nonexistent) |
@@ -1,90 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: fab_tool.h,v 1.1 2002-10-01 10:25:03 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: FAB_tool.h * |
- * libreria: FAB_LIB * |
- * version: 1.0 25/08/2002 * |
- * creato da: Fabio CALABRESE * |
- * * |
- **************************************************** |
- * * |
- * descrizione: tool di funzioni d'utilita' * |
- * * |
- ****************************************************/ |
- |
-#ifndef __FAB_LIB__FAB_tool_h__ |
-#define __FAB_LIB__FAB_tool_h__ |
-//-------------------BEGIN--------------------------- |
- |
-// *** Librerie S.Ha.R.K *** |
-// *** Librerie Standard C *** |
-#include <stdlib.h> |
-#include <math.h> |
-// *** Librerie FAB *** |
- |
-// ----------- |
-// Definizioni |
-//---------------------- |
-//---------------------- |
- |
-// ---------------- |
-// Funzioni & Macro |
-//------------------------------------------------- |
-#define FAB_PI 3.141592654 |
-#define FAB_grad(RADIANTI) RADIANTI/FAB_PI*180 |
-#define FAB_rad(GRADI) GRADI/180.0*FAB_PI |
-#define FAB_set_ang360(ANGOLO,X,Y) if ((X)>0) {if((Y)>0) (ANGOLO)=atan((Y)/(double)(X));else if((Y)<0) (ANGOLO)=atan((Y)/(double)(X))+2*FAB_PI;else (ANGOLO)=0;}else if ((X)<0) (ANGOLO)=atan((Y)/(double)(X))+FAB_PI;else /* X==0 */if ((Y)>0) (ANGOLO)=FAB_PI/2;else if ((Y)<0) (ANGOLO)=FAB_PI/2+FAB_PI;else /* Y==0 */ (ANGOLO)=-1; /* X=Y=0 */ |
-#define FAB_set_xy360(X,Y,MODULO,ANGOLO) (X)=(MODULO)*cos(ANGOLO);(Y)=(MODULO)*sin(ANGOLO); |
- |
-#define FAB_ABS(X) ((X) > 0 ? (X) : (X)*-1) |
- |
-#define FAB_sign_rand() (rand()%2 ? -1 : +1) |
-#define FAB_int_rand(MIN,MAX ) ((MIN) + rand()%((MAX)-(MIN)+1)) |
-#define FAB_double_rand(MIN,MAX) ((MIN) + ((MAX)-(MIN))*((double)rand()/RAND_MAX)) |
-//-------------------------------------------------- |
- |
- |
-// Altro... |
- |
-//----------------------END-------------------------- |
-#endif |
Index: tags/rel_1_4_rc1/bca/scenario.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/scenario.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/scenario.c (nonexistent) |
@@ -1,168 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: scenario.c,v 1.1 2002-10-01 10:25:01 pj Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-//*************************** |
-//* file: scenario.c * |
-//* included by: bca.c * |
-//*************************** |
- |
-void scenario_ca() |
-{ //SFONDO |
- FAB_image_fill(image_sfondo,0,0,800,600); |
- |
- //FRAME_BCA |
- FAB_frame_put(frame_bca,X0-7,Y0-7,500+7*2,500+7*2); |
-} |
-void scenario_misure() |
-{ int x, y, cx, cy; |
- char* str_km ="X.Xkm"; |
- char* str_m ="XXXXm"; |
- int h; |
- |
- //FRAME_MISURE orizzontale |
- FAB_frame_put(frame_misure_oriz, X0-7, Y1+7+20-7, |
- 500+7*2, FRAME_MISURE_ORIZ_LY+7*2); |
- cy = frame_misure_oriz->y0 + 10; |
- cx = frame_misure_oriz->x0 + |
- (frame_misure_oriz->x1 - frame_misure_oriz->x0) / 2; |
- for(x=frame_misure_oriz->x0 ;x<frame_misure_oriz->x1+1 ;x+=5) |
- grx_line(x,cy,x+2,cy,FRAME_MISURE_LINE_COLOR); |
- for(y=frame_misure_oriz->y0; y<cy-1; y+=5) { |
- grx_line(frame_misure_oriz->x0,y,frame_misure_oriz->x0,y+2,FRAME_MISURE_LINE_COLOR); |
- grx_line(cx,y,cx,y+2,FRAME_MISURE_LINE_COLOR); |
- grx_line(frame_misure_oriz->x1,y,frame_misure_oriz->x1,y+2,FRAME_MISURE_LINE_COLOR); |
- } |
- sprintf(str_km,"%02.1fkm",0.0); |
- grx_text(str_km,frame_misure_oriz->x0+10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
- sprintf(str_km,"%02.1fkm",BASE_L/2.0); |
- grx_text(str_km,cx-10,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
- sprintf(str_km,"%02.1fkm",BASE_L); |
- grx_text(str_km,frame_misure_oriz->x1-FRAME_MISURE_ORIZ_LY,cy+2,FRAME_MISURE_LINE_COLOR,frame_misure_oriz->color); |
- |
- //FRAME_MISURE verticale |
- FAB_frame_put(frame_misure_vert, X1+7+20-7, Y0-7, |
- FRAME_MISURE_VERT_LX+7*2, 500+7*2); |
- cy = frame_misure_vert->y0 + |
- (frame_misure_vert->y1 - frame_misure_vert->y0) / 2; |
- cx = frame_misure_vert->x0 + 10; |
- for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; y-=5) |
- grx_line(cx,y,cx,y-2,FRAME_MISURE_LINE_COLOR); |
- h=0; |
- for(y=frame_misure_vert->y1; y>frame_misure_vert->y0-1; |
- y-=500.0*(X1-X0)/BASE_H, h+=500) { |
- for(x=frame_misure_vert->x0; x<cx-1; x+=5) |
- grx_line(x,y,x+2,y,FRAME_MISURE_LINE_COLOR); |
- sprintf(str_m,"%dm",h); |
- grx_text(str_m, cx+2, y-6, |
- FRAME_MISURE_LINE_COLOR, frame_misure_vert->color); |
- } |
-} |
-void scenario_radar() |
-{ FAB_ballframe_put(ballframe_radar, |
- frame_bca->x1+7+30, frame_bca->y1+7+30, 30); |
- FAB_ballframe_put(ballframe_lucerossa[2],605,546,20); |
- FAB_ballframe_put(ballframe_lucerossa[1],594,578,15); |
- FAB_ballframe_put(ballframe_lucerossa[0],574,591,10); |
-} |
-void scenario_titolo() |
-{ int x0,y0; |
- x0 = frame_misure_vert->x1+7+20-7; |
- y0 = frame_bca->y0-7; |
- FAB_frame_put(frame_titolo,x0,y0,800-x0-20+7,170); |
- x0 = frame_titolo->x0; |
- y0 = frame_titolo->y0; |
- grx_text(titolo[0],x0+2,y0+10,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[1],x0+2,y0+20,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[2],x0+2,y0+30,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[3],x0+2,y0+46,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[4],x0+2,y0+66,FRAME_TITOLO_TEXT_COLOR1,FRAME_TITOLO_BACK_COLOR2); |
- grx_text(titolo[5],x0+2,y0+81,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[6],x0+2,y0+96,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[7],x0+2,y0+116,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[8],x0+2,y0+133,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
- grx_text(titolo[9],x0+2,y0+141,FRAME_TITOLO_TEXT_COLOR2,FRAME_TITOLO_BACK_COLOR1); |
-} |
-void scenario_comandi() |
-{ int x0, y0; |
- x0 = frame_misure_vert->x1+7+20-7; |
- y0 = frame_titolo->y1+7+20-7; |
- FAB_frame_put(frame_comandi,x0,y0,800-x0-20+7,100+7*2); |
- x0 = frame_comandi->x0; |
- y0 = frame_comandi->y0; |
- grx_text(" COMANDI \0",x0+2,y0+10,FRAME_COMANDI_TEXT_COLOR1,FRAME_COMANDI_BACK_COLOR1); |
- grx_text("-------------------\0",x0+2,y0+20,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
- grx_text(" esci \0",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
- grx_text("[INVIO]",x0+2,y0+40,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
- grx_text(" +/- aerei \0",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
- grx_text("[1/2]",x0+2,y0+60,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
- grx_text(" +/- cannoni\0",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR2,FRAME_COMANDI_BACK_COLOR1); |
- grx_text("[3/4]",x0+2,y0+80,FRAME_COMANDI_TEXT_COLOR3,FRAME_COMANDI_BACK_COLOR2); |
-} |
-void scenario_control() |
-{ int x0,y0; |
- |
- x0 = frame_misure_vert->x1+7+20-7; |
- y0 = frame_comandi->y1+7+20-7; |
- FAB_frame_put(frame_control,x0,y0,800-x0-20+7,frame_misure_vert->y1+7-y0); |
- x0 = frame_control->x0; |
- y0 = frame_control->y0; |
- grx_text(" CONTROL \0",x0+2, y0+5,FRAME_CONTROL_TEXT_COLOR2,FRAME_CONTROL_BACK_COLOR); |
- grx_line(x0-3, y0+15, |
- frame_control->x1+3, y0+15, |
- FRAME_CONTROL_TEXT_COLOR1); |
- |
- grx_line(x0-3, frame_control->y1-81, |
- frame_control->x1+3, frame_control->y1-81, |
- FRAME_CONTROL_TEXT_COLOR1); |
-} |
-void scenario() |
-{ scenario_ca(); |
- scenario_misure(); |
- scenario_radar(); |
- scenario_titolo(); |
- scenario_comandi(); |
- scenario_control(); |
-} |
- |
-void info() |
-{ int i; |
- for(i=0; i<10; i++) kern_printf("%s\n",titolo[i]); |
-} |
Index: tags/rel_1_4_rc1/bca/initfile.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/initfile.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/initfile.c (nonexistent) |
@@ -1,230 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Giacomo Guidi <giacomo@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-#define PI_MUTEX |
- |
-#include "kernel/kern.h" |
-#include "modules/intdrive.h" |
-#include "modules/edf.h" |
-#include "modules/hardcbs.h" |
-#include "modules/rr.h" |
-#include "modules/dummy.h" |
- |
-#include "modules/sem.h" |
-#include "modules/hartport.h" |
-#include "modules/cabs.h" |
- |
-#include "modules/pi.h" |
-#include "modules/nop.h" |
- |
-#include "bca.h" |
- |
-#include <drivers/shark_linuxc26.h> |
-#include <drivers/shark_pci26.h> |
-#include <drivers/shark_input26.h> |
-#include <drivers/shark_keyb26.h> |
-#include <drivers/shark_fb26.h> |
- |
-#define FRAME_BUFFER_DEVICE 0 |
- |
-/*+ sysyem tick in us +*/ |
-#define TICK 0 |
- |
-/*+ RR tick in us +*/ |
-#define RRTICK 2000 |
- |
-/*+ Interrupt Server +*/ |
-#define INTDRIVE_Q 1000 |
-#define INTDRIVE_T 10000 |
-#define INTDRIVE_FLAG 0 |
- |
-void call_shutdown_task(void *arg); |
-int device_drivers_init(); |
-int device_drivers_close(); |
-void set_shutdown_task(); |
-TASK shutdown_task_body(void *arg); |
- |
-PID shutdown_task_PID = -1; |
- |
-TIME __kernel_register_levels__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
- EDF_register_level(EDF_ENABLE_ALL); |
- HCBS_register_level(HCBS_ENABLE_ALL, 1); |
- RR_register_level(RRTICK, RR_MAIN_YES, mb); |
- dummy_register_level(); |
- |
- SEM_register_module(); |
- CABS_register_module(); |
- |
- PI_register_module(); |
- NOP_register_module(); |
- |
- kern_init_bca(); |
- |
- return TICK; |
-} |
- |
-TASK __init__(void *arg) |
-{ |
- struct multiboot_info *mb = (struct multiboot_info *)arg; |
- |
- HARTPORT_init(); |
- |
- /* Create the shutdown task. It will be activated at RUNLEVEL |
- SHUTDOWN */ |
- set_shutdown_task(); |
- |
- /* Init the drivers */ |
- device_drivers_init(); |
- |
- /* Set the shutdown task activation */ |
- sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
- |
- __call_main__(mb); |
- |
- return (void *)0; |
-} |
- |
-#ifdef PI_MUTEX |
-int app_mutex_init(mutex_t *m) |
-{ |
- PI_mutexattr_t attr; |
- |
- PI_mutexattr_default(attr); |
- |
- return mutex_init(m, &attr); |
-} |
-#else |
-int app_mutex_init(mutex_t *m) |
-{ |
- NOP_mutexattr_t attr; |
- |
- NOP_mutexattr_default(attr); |
- |
- return mutex_init(m, &attr); |
-} |
-#endif |
- |
-void set_shutdown_task() { |
- |
- /* WARNING: the shutdown task is a background thread. It cannot execute |
- if the system is overloaded */ |
- NRT_TASK_MODEL nrt; |
- |
- nrt_task_default_model(nrt); |
- nrt_task_def_system(nrt); |
- |
- shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
- if (shutdown_task_PID == NIL) { |
- sys_shutdown_message("Error: Cannot create shutdown task\n"); |
- sys_end(); |
- } |
- |
-} |
- |
-int device_drivers_init() { |
- |
- int res; |
- KEYB_PARMS kparms = BASE_KEYB; |
- |
- LINUXC26_register_module(); |
- |
- PCI26_init(); |
- |
- INPUT26_init(); |
- |
- keyb_def_ctrlC(kparms, NULL); |
- |
- KEYB26_init(&kparms); |
- |
- FB26_init(); |
- |
- res = FB26_open(FRAME_BUFFER_DEVICE); |
- if (res) { |
- cprintf("Error: Cannot open graphical mode\n"); |
- KEYB26_close(); |
- INPUT26_close(); |
- sys_end(); |
- } |
- |
- FB26_use_grx(FRAME_BUFFER_DEVICE); |
- |
- FB26_setmode(FRAME_BUFFER_DEVICE,"800x600-16"); |
- |
- return 0; |
- |
-} |
- |
-int device_drivers_close() { |
- |
- FB26_close(FRAME_BUFFER_DEVICE); |
- |
- KEYB26_close(); |
- |
- INPUT26_close(); |
- |
- return 0; |
- |
-} |
- |
-#define SHUTDOWN_TIMEOUT_SEC 3 |
- |
-void call_shutdown_task(void *arg) |
-{ |
- struct timespec t; |
- |
- sys_gettime(&t); |
- t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
- |
- /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
- kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
- |
- task_activate(shutdown_task_PID); |
-} |
- |
-TASK shutdown_task_body(void *arg) { |
- |
- device_drivers_close(); |
- |
- sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
- |
- sys_abort_shutdown(0); |
- |
- return NULL; |
- |
-} |
Index: tags/rel_1_4_rc1/bca/missile.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/missile.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/missile.c (nonexistent) |
@@ -1,202 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: missile.c,v 1.3 2004-05-25 18:24:59 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-//************************** |
-//* file: missile.c * |
-//* included by: bca.c * |
-//************************** |
- |
-PID crea_hard_missile(int index); |
-PID crea_soft_missile(int index); |
-PID crea_soft_esplo(int index); |
- |
-TASK missile(void *arg) |
-{ |
- PID esplo_pid; |
- int img; |
- int i, index; // indice nella cannone_table |
- int distx, disty; |
- int xx0,yy0,xx1,yy1; |
- double vel, acc; |
- double a; |
- double y; |
- double x; |
- double old_x; // [pixel]: conserva valore x prima di aggiornare |
- double old_y; |
- double dx; // [pixel/us]: spostamento periodico |
- double dy; |
- int first_time; |
- int killing; |
- |
- index = (int)arg; |
- img=0; |
- y = MISSILE_Y_MAX; |
- x = cannone_table[index].x; |
- a = FAB_rad(270); |
- vel = MISSILE_V_MIN; |
- acc = MISSILE_ACC_MIN; |
- dx = 0; |
- dy = 0; |
- |
- first_time = 1; |
- killing = 0; |
- |
- while(1){ |
- |
- old_x = x; |
- old_y = y; |
- |
- if (vel<MISSILE_V_MAX) { |
- vel += acc*MISSILE_PERIOD/(60*60*1000000.0); |
- if (vel>MISSILE_V_MAX) vel = MISSILE_V_MAX; |
- } |
- if (acc<MISSILE_ACC_MAX) { |
- acc += MISSILE_ACC_MIN; |
- if (acc>MISSILE_ACC_MAX) acc = MISSILE_ACC_MAX; |
- } |
- |
- cannone_table[index].missile_vel=vel; |
- |
- dx = cos(a)*vel * (X1-X0) / (double)BASE_L |
- * (MISSILE_PERIOD / (60*60*1000000.0)); |
- dy = sin(a)*vel * (Y1-Y0) / ((double)BASE_H/1000) |
- * (MISSILE_PERIOD / (60*60*1000000.0)); |
- |
- x += dx; |
- y += dy; |
- |
- xx0 = old_x - MISSILE_LX/2; |
- yy0 = old_y - MISSILE_LY/2; |
- xx1 = xx0 + MISSILE_LX-1; |
- yy1 = yy0 + MISSILE_LY-1; |
- |
- if (x<MISSILE_X_MIN || x>MISSILE_X_MAX |
- || y<MISSILE_Y_MIN || y>MISSILE_Y_MAX) { |
- killing = 1; |
- } |
- |
- if (killing) { |
- if (!first_time) { |
- mutex_lock(&grx_mutex); |
- FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
- mutex_unlock(&grx_mutex); |
- } |
- cannone_table[index].fire = 0; |
- //il task cannone si accorge che il suo missile ha finito |
- // quindi ne ricreer
uno nuovo in caso di bersaglio!!! |
- return NULL; |
- } |
- |
- if ( (int)x != (int)old_x |
- ||(int)y != (int)old_y ) {//...se c' lo spostamento reale |
- // di almeno un pixel... |
- mutex_lock(&grx_mutex); //...aggiorna disegno... |
- if (first_time) { |
- first_time=0; |
- } |
- else { |
- if (yy1<Y1-CANNONE_LY) FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,yy1); |
- else FAB_image_put_within(image_bca,X0,Y0,xx0,yy0,xx1,Y1-CANNONE_LY); |
- } |
- |
- FAB_image_put_within(image_missile[img++], x - MISSILE_LX/2, y - MISSILE_LY/2, |
- X0, Y0, |
- X1, Y1-CANNONE_LY); |
- mutex_unlock(&grx_mutex); |
- if (img==2) img = 0; |
- } |
- |
- //Ha colpito un aereo? |
- for (i=0; i<AEREO_N_MAX; i++) |
- if (aereo_table[i].status){ |
- distx = aereo_table[i].x-x; |
- disty = aereo_table[i].y-y; |
- if (distx<0) distx *= -1; |
- if (disty<0) disty *= -1; |
- if ( distx<(AEREO_LX+MISSILE_LX)/2-1 |
- &&disty<(AEREO_LY+MISSILE_LY)/2-1 ) { // BERSAGLIO COLPITO! |
- esplo_pid = crea_soft_esplo(i); |
- task_activate(esplo_pid); |
- killing=1; |
- aereo_table[i].killing=1; |
- break; |
- } |
- } |
- |
- task_endcycle(); |
- } |
- |
-return NULL; |
-} |
- |
- |
-PID crea_hard_missile(int index) |
-{ |
- HARD_TASK_MODEL m; |
- PID pid; |
- |
- hard_task_default_model(m); |
- hard_task_def_level(m,1); |
- hard_task_def_arg(m,(void*)index); |
- hard_task_def_periodic(m); |
- hard_task_def_wcet(m, MISSILE_WCET); |
- hard_task_def_mit(m,MISSILE_PERIOD); |
- |
- pid = task_create("hard_missile", missile, &m, NULL); |
- return pid; |
-} |
- |
-PID crea_soft_missile(int index) |
-{ |
- SOFT_TASK_MODEL m; |
- PID pid; |
- |
- soft_task_default_model(m); |
- soft_task_def_level(m,2); |
- soft_task_def_arg(m,(void*)index); |
- soft_task_def_periodic(m); |
- soft_task_def_period(m,MISSILE_PERIOD); |
- soft_task_def_wcet(m, MISSILE_WCET); |
- soft_task_def_met(m,MISSILE_MET); |
- |
- pid = task_create("soft_missile", missile, &m, NULL); |
- return pid; |
-} |
Index: tags/rel_1_4_rc1/bca/bca_lib.c |
=================================================================== |
--- tags/rel_1_4_rc1/bca/bca_lib.c (revision 1476) |
+++ tags/rel_1_4_rc1/bca/bca_lib.c (nonexistent) |
@@ -1,412 +0,0 @@ |
-/* |
- * Project: S.Ha.R.K. |
- * |
- * Coordinators: |
- * Giorgio Buttazzo <giorgio@sssup.it> |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * |
- * Authors : |
- * Paolo Gai <pj@gandalf.sssup.it> |
- * Massimiliano Giorgi <massy@gandalf.sssup.it> |
- * Luca Abeni <luca@gandalf.sssup.it> |
- * (see the web pages for full authors list) |
- * |
- * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
- * |
- * http://www.sssup.it |
- * http://retis.sssup.it |
- * http://shark.sssup.it |
- */ |
- |
-/* CVS : $Id: bca_lib.c,v 1.4 2004-05-23 08:59:27 giacomo Exp $ */ |
- |
-/* |
- * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
- * |
- * This program is free software; you can redistribute it and/or modify |
- * it under the terms of the GNU General Public License as published by |
- * the Free Software Foundation; either version 2 of the License, or |
- * (at your option) any later version. |
- * |
- * This program is distributed in the hope that it will be useful, |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- * GNU General Public License for more details. |
- * |
- * You should have received a copy of the GNU General Public License |
- * along with this program; if not, write to the Free Software |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
- * |
- */ |
- |
-/**************************************************** |
- * * |
- * file: BCA_LIB.c * |
- * libreria: BCA_LIB * |
- * creato da: Fabio CALABRESE * |
- * * |
- ****************************************************/ |
- |
-#ifndef __BCA_LIB_c__ |
-#define __BCA_LIB_c__ |
-//-------------------BEGIN--------------------------- |
- |
-// *** Librerie S.Ha.R.K *** |
-#include<kernel/kern.h> |
- |
-#include<drivers/shark_fb26.h> |
- |
-// *** Librerie Standard C *** |
-// *** Librerie FAB *** |
-#include"fab_lib/fab_msg.h" |
-// *** Librerie BCA *** |
-#include"bca.h" |
- |
-char * titolo[10]={" UNIVERSITA' DEGLI \0", |
- " STUDI DI \0", |
- " PAVIA \0", |
- "Progetto S.Ha.R.K.\0", |
- " 'BaseContrAerea' \0", |
- "-------------------\0", |
- " PAVIA 2002 \0", |
- "by Fabio CALABRESE \0", |
- "<fabiocalabrese77 \0", |
- " @yahoo.it>\0"}; |
- |
-void kern_alloc_images(); // richiede DISABLED_INTERUPTS |
-void kern_free_images(); // richiede DISABLED_INTERUPTS |
-void kern_load_images(); // solo in __kernel_register_levels__() |
- |
-void kern_alloc_borders(); // richiede DISABLED_INTERUPTS |
-void kern_free_borders(); // richiede DISABLED_INTERUPTS |
-void kern_set_border(); // consigliato in __kernel_register-levels__() |
- |
-void kern_alloc_frames(); // richiede DISABLED_INTERUPTS |
-void kern_free_frames(); // richiede DISABLED_INTERUPTS |
-void kern_set_frames(); // consigliato in __kernel_register-levels__() |
- |
-void kern_alloc_ballframes(); // richiede DISABLED_INTERUPTS |
-void kern_free_ballframes(); // richiede DISABLED_INTERUPTS |
-void kern_set_ballframes(); // consigliato in __kernel_register-levels__() |
- |
-void kern_alloc_task_tables(); // richiede DISABLED_INTERUPTS |
-void kern_free_task_tables(); // richiede DISABLED_INTERUPTS |
-void kern_set_task_tables(); // consigliato in __kernel_register-levels__() |
- |
-void kern_alloc_task_tables() |
-{ |
- int test=0,j; |
- |
- FAB_print("TASKS'TABLES","allocazione..."); |
- for (j=0; j<AEREO_N_MAX; j++) { |
- aereo_table[j].image=FAB_image_alloc(AEREO_LX,AEREO_LY); |
- if(aereo_table[j].image==NULL) test=1; |
- } |
- FAB_msg(test,"fatto","almeno un elemento della tabella non allocato"); |
-} |
-void kern_free_task_tables() |
-{ int j; |
- |
- for (j=0; j<AEREO_N_MAX; j++) { |
- FAB_image_free(aereo_table[j].image); |
- } |
-} |
-void kern_set_task_tables() |
-{ int j; |
- |
- FAB_print(NULL,"settaggio..."); |
- for (j=0; j<AEREO_N_MAX; j++) { |
- aereo_table[j].status = 0; |
- aereo_table[j].killing = 0; |
- aereo_table[j].image->trasparent = 1; |
- aereo_table[j].image->trasparent_col = AEREO_TRASPARENT_COL; |
- } |
- |
- FAB_print(NULL,"fatto"); |
-} |
- |
- |
-void kern_alloc_ballframes() |
-{ |
- int test=0,j; |
- |
- FAB_print("FAB_BALLFRAMEs","allocazione..."); |
- ballframe_radar = FAB_ballframe_alloc(); |
- if (ballframe_radar==NULL) test=1; |
- for (j=0; j<3; j++) { |
- ballframe_lucerossa[j] = FAB_ballframe_alloc(); |
- if (ballframe_lucerossa[j]==NULL) test=1; |
- } |
- FAB_msg(test,"fatto","almeno un ballframe non allocato"); |
-} |
-void kern_free_ballframes() |
-{ int j; |
- |
- FAB_ballframe_free(ballframe_radar); |
- for (j=0; j<3; j++) |
- FAB_ballframe_free(ballframe_lucerossa[j]); |
-} |
-void kern_set_ballframes() |
-{ int j; |
- |
- FAB_print(NULL,"settaggio..."); |
- FAB_ballframe_border_set(ballframe_radar,border_verde7,7, |
- FRAME_MISURE_LINE_COLOR); |
- FAB_ballframe_color_set(ballframe_radar,0,FAB_blue); |
- for(j=0; j<3; j++) { |
- FAB_ballframe_border_set(ballframe_lucerossa[j],border_verde7,7, |
- FRAME_MISURE_LINE_COLOR); |
- FAB_ballframe_color_set(ballframe_lucerossa[j],0,FAB_red); |
- } |
- FAB_print(NULL,"fatto"); |
-} |
- |
-void kern_alloc_frames() |
-{ |
- int test=0; |
- |
- FAB_print("FAB_FRAMEs","allocazione..."); |
- frame_bca = FAB_frame_alloc(); |
- if (frame_bca==NULL) test=1; |
- frame_misure_oriz = FAB_frame_alloc(); |
- if (frame_misure_oriz==NULL) test=1; |
- frame_misure_vert = FAB_frame_alloc(); |
- if (frame_misure_vert==NULL) test=1; |
- frame_titolo = FAB_frame_alloc(); |
- if (frame_titolo==NULL) test=1; |
- frame_comandi = FAB_frame_alloc(); |
- if (frame_comandi==NULL) test=1; |
- frame_control = FAB_frame_alloc(); |
- if (frame_control==NULL) test=1; |
- |
- FAB_msg(test,"fatto","almeno un frame non allocato"); |
-} |
-void kern_free_frames() |
-{ |
- FAB_frame_free(frame_bca); |
- FAB_frame_free(frame_misure_oriz); |
- FAB_frame_free(frame_misure_vert); |
- FAB_frame_free(frame_titolo); |
- FAB_frame_free(frame_comandi); |
- FAB_frame_free(frame_control); |
- |
-} |
- |
-void kern_set_frames() |
-{ |
- FAB_print(NULL,"settaggio..."); |
- FAB_frame_border_set(frame_bca,border_blu7,7,FAB_rgb(255,0,0)); |
- FAB_frame_color_set(frame_bca,0,image_bca,FAB_green); |
- FAB_frame_border_set(frame_misure_oriz,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
- FAB_frame_color_set(frame_misure_oriz,0,NULL,FRAME_MISURE_BACK_COLOR); |
- FAB_frame_border_set(frame_misure_vert,border_verde7,7,FRAME_MISURE_LINE_COLOR); |
- FAB_frame_color_set(frame_misure_vert,0,NULL,FRAME_MISURE_BACK_COLOR); |
- FAB_frame_border_set(frame_titolo,border_bianco7,7,FAB_white); |
- FAB_frame_color_set(frame_titolo,0,NULL,FRAME_TITOLO_BACK_COLOR1); |
- FAB_frame_border_set(frame_comandi,border_giallo7,7,FAB_yellow); |
- FAB_frame_color_set(frame_comandi,0,NULL,FRAME_COMANDI_BACK_COLOR1); |
- FAB_frame_border_set(frame_control,border_verde7,7,FAB_green); |
- FAB_frame_color_set(frame_control,0,NULL,FRAME_CONTROL_BACK_COLOR); |
- |
- FAB_print(NULL,"fatto"); |
-} |
- |
-void kern_alloc_borders() |
-{ |
- int test=0; |
- |
- FAB_print("FAB_BORDERs","allocazione..."); |
- border_blu7 = FAB_border_alloc(7); |
- if (border_blu7==NULL) test=1; |
- border_verde7 = FAB_border_alloc(7); |
- if (border_verde7==NULL) test=1; |
- border_rosso7 = FAB_border_alloc(7); |
- if (border_rosso7==NULL) test=1; |
- border_bianco7 = FAB_border_alloc(7); |
- if (border_bianco7==NULL) test=1; |
- border_giallo7 = FAB_border_alloc(7); |
- if (border_giallo7==NULL) test=1; |
- |
- FAB_msg(test,"fatto","almeno un bordo non allocato"); |
-} |
-void kern_free_borders() |
-{ |
- FAB_border_free(border_blu7); |
- FAB_border_free(border_verde7); |
- FAB_border_free(border_rosso7); |
- FAB_border_free(border_bianco7); |
- FAB_border_free(border_giallo7); |
-} |
- |
-void kern_set_borders() |
-{ |
- FAB_print(NULL,"settaggio..."); |
- border_blu7->buf[0]=FAB_rgb( 0, 0, 50); |
- border_blu7->buf[1]=FAB_rgb( 0, 50,200); |
- border_blu7->buf[2]=FAB_rgb( 50,100,255); |
- border_blu7->buf[3]=FAB_rgb(100,150,255); |
- border_blu7->buf[4]=FAB_rgb( 50,100,255); |
- border_blu7->buf[5]=FAB_rgb( 0, 50,200); |
- border_blu7->buf[6]=FAB_rgb( 0, 0, 50); |
- |
- border_verde7->buf[0]=FAB_rgb( 0, 50, 0); |
- border_verde7->buf[1]=FAB_rgb( 0,100, 50); |
- border_verde7->buf[2]=FAB_rgb( 50,255,100); |
- border_verde7->buf[3]=FAB_rgb(100,255,150); |
- border_verde7->buf[4]=FAB_rgb( 50,255,100); |
- border_verde7->buf[5]=FAB_rgb( 0,100, 50); |
- border_verde7->buf[6]=FAB_rgb( 0, 50, 0); |
- |
- border_rosso7->buf[0]=FAB_rgb( 50, 0, 0); |
- border_rosso7->buf[1]=FAB_rgb(200, 25, 25); |
- border_rosso7->buf[2]=FAB_rgb(255, 75, 75); |
- border_rosso7->buf[3]=FAB_rgb(255,125,125); |
- border_rosso7->buf[4]=FAB_rgb(255, 75, 75); |
- border_rosso7->buf[5]=FAB_rgb(200, 25, 25); |
- border_rosso7->buf[6]=FAB_rgb( 50, 0, 0); |
- |
- border_bianco7->buf[0]=FAB_rgb( 25, 25, 25); |
- border_bianco7->buf[1]=FAB_rgb( 75, 75, 75); |
- border_bianco7->buf[2]=FAB_rgb(125,125,125); |
- border_bianco7->buf[3]=FAB_rgb(255,255,255); |
- border_bianco7->buf[4]=FAB_rgb(125,125,125); |
- border_bianco7->buf[5]=FAB_rgb( 75, 75, 75); |
- border_bianco7->buf[6]=FAB_rgb( 25, 25, 25); |
- |
- border_giallo7->buf[0]=FAB_rgb( 25, 25, 0); |
- border_giallo7->buf[1]=FAB_rgb(115,115, 25); |
- border_giallo7->buf[2]=FAB_rgb(170,170, 75); |
- border_giallo7->buf[3]=FAB_rgb(255,255,100); |
- border_giallo7->buf[4]=FAB_rgb(170,170, 75); |
- border_giallo7->buf[5]=FAB_rgb(115,115, 25); |
- border_giallo7->buf[6]=FAB_rgb( 25, 25, 0); |
- |
- FAB_print(NULL,"fatto"); |
-} |
- |
-void kern_alloc_images() |
-{ |
- int j,test=0; |
- |
- FAB_print("FAB_IMAGEs","allocazione..."); |
- |
- image_missile[0] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
- if (image_missile[0]==NULL) test=1; |
- image_missile[1] = FAB_image_alloc(MISSILE_LX,MISSILE_LY); |
- if (image_missile[1]==NULL) test=1; |
- |
- for (j=0; j<2; j++) { |
- image_cannone[j] = FAB_image_alloc(CANNONE_LX,CANNONE_LY); |
- if (image_cannone[j]==NULL) test=1; |
- } |
- |
- for (j=0; j<4; j++) { |
- image_aereo[j] = FAB_image_alloc(AEREO_LX,AEREO_LY); |
- if (image_aereo[j]==NULL) test=1; |
- } |
- |
- for (j=0; j<5; j++) { |
- image_esplo[j] = FAB_image_alloc(ESPLO_LX,ESPLO_LY); |
- if (image_esplo[j]==NULL) test=1; |
- } |
- |
- image_sfondo = FAB_image_alloc(96,96); |
- if (image_sfondo==NULL) test=1; |
- |
- image_bca = FAB_image_alloc(500,500); |
- if (image_bca==NULL) test=1; |
- |
- FAB_msg(test,"fatto","almeno un'immagine non allocata"); |
-} |
-void kern_free_images() |
-{ |
- int j; |
- |
- FAB_image_free(image_missile[0]); |
- FAB_image_free(image_missile[1]); |
- for (j=0; j<2; j++) FAB_image_free(image_cannone[j]); |
- for (j=0; j<4; j++) FAB_image_free(image_aereo[j]); |
- for (j=0; j<5; j++) FAB_image_free(image_esplo[j]); |
- FAB_image_free(image_sfondo); |
- FAB_image_free(image_bca); |
-} |
- |
-void kern_load_images() |
-{ int test=0; |
- |
- FAB_print(NULL,"caricamento dai file..."); |
- |
- FAB_print(NULL," [missile1.raw]..."); |
- if(FAB_image_load(image_missile[0],"BCA_raw/missile1.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_missile[0],MISSILE_TRASPARENT_COL); |
- FAB_print(NULL," [missile2.raw]..."); |
- if(FAB_image_load(image_missile[1],"BCA_raw/missile2.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_missile[1],MISSILE_TRASPARENT_COL); |
- |
- FAB_print(NULL," [aereo1.raw]..."); |
- if(FAB_image_load(image_aereo[0],"BCA_raw/aereo1.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_aereo[0],AEREO_TRASPARENT_COL); |
- FAB_print(NULL," [aereo2.raw]..."); |
- if(FAB_image_load(image_aereo[1],"BCA_raw/aereo2.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_aereo[1],AEREO_TRASPARENT_COL); |
- FAB_print(NULL," [aereo1_h.raw]..."); |
- if(FAB_image_load(image_aereo[2],"BCA_raw/aereo1_h.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_aereo[2],AEREO_TRASPARENT_COL); |
- FAB_print(NULL," [aereo2_h.raw]..."); |
- if(FAB_image_load(image_aereo[3],"BCA_raw/aereo2_h.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_aereo[3],AEREO_TRASPARENT_COL); |
- |
- FAB_print(NULL," [cannon.raw]..."); |
- if(FAB_image_load(image_cannone[0],"BCA_raw/cannon.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_cannone[0],CANNONE_TRASPARENT_COL); |
- FAB_print(NULL," [cannon_h.raw]..."); |
- if(FAB_image_load(image_cannone[1],"BCA_raw/cannon_h.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_cannone[1],CANNONE_TRASPARENT_COL); |
- |
- FAB_print(NULL," [esplo1.raw]..."); |
- if(FAB_image_load(image_esplo[0],"BCA_raw/esplo1.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_esplo[0],ESPLO_TRASPARENT_COL); |
- FAB_print(NULL," [esplo2.raw]..."); |
- if(FAB_image_load(image_esplo[1],"BCA_raw/esplo2.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_esplo[1],ESPLO_TRASPARENT_COL); |
- FAB_print(NULL," [esplo3.raw]..."); |
- if(FAB_image_load(image_esplo[2],"BCA_raw/esplo3.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_esplo[2],ESPLO_TRASPARENT_COL); |
- FAB_print(NULL," [esplo4.raw]..."); |
- if(FAB_image_load(image_esplo[3],"BCA_raw/esplo4.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_esplo[3],ESPLO_TRASPARENT_COL); |
- FAB_print(NULL," [esplo5.raw]..."); |
- if(FAB_image_load(image_esplo[4],"BCA_raw/esplo5.raw")==-1) test=1; |
- FAB_image_trasparent_set(image_esplo[4],ESPLO_TRASPARENT_COL); |
- |
- FAB_print(NULL," [sfondo.raw]..."); |
- if(FAB_image_load(image_sfondo,"BCA_raw/sfondo.raw")==-1) test=1; |
- FAB_image_no_trasparent_set(image_sfondo); |
- |
- FAB_print(NULL," [bca.raw]..."); |
- if(FAB_image_load(image_bca,"BCA_raw/bca.raw")==-1) test=1; |
- FAB_image_no_trasparent_set(image_bca); |
- |
- FAB_msg(test,"fatto","almeno un file non esiste oppure ha un formato incompatibile"); |
-} |
- |
-// *** Corpo delle funzioni in CA.h *** // |
-void kern_init_bca() |
-{ |
- FAB_clr(); |
- |
- kern_alloc_task_tables(); |
- kern_set_task_tables(); |
- |
- kern_alloc_borders(); |
- kern_set_borders(); |
- kern_alloc_images(); |
- kern_load_images(); |
- kern_alloc_frames(); |
- kern_set_frames(); |
- kern_alloc_ballframes(); |
- kern_set_ballframes(); |
-} |
- |
-//----------------------END-------------------------- |
-#endif |
Index: tags/rel_1_4_rc1/bca/readme |
=================================================================== |
--- tags/rel_1_4_rc1/bca/readme (revision 1476) |
+++ tags/rel_1_4_rc1/bca/readme (nonexistent) |
@@ -1,11 +0,0 @@ |
-Hi, |
- |
-This is a nice simulation made by Fabio Calabrese |
-(fabiocalabrese77@yahoo.it). |
- |
-Documentation is also available in PDF form on the shark website (only |
-in italian, sorry). |
- |
-Enjoy |
- |
-PJ |
Index: tags/rel_1_4_rc1/bca/bca_raw/aereo2_h.raw |
=================================================================== |
--- tags/rel_1_4_rc1/bca/bca_raw/aereo2_h.raw (revision 1476) |
+++ tags/rel_1_4_rc1/bca/bca_raw/aereo2_h.raw (nonexistent) |
@@ -1 +0,0 @@ |
-ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ÿÿÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ¿¿¿ÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ÿÿÿÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ÿÿÿÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ÿÿÿÿÿÿÿÿ ÿÿ ÿ ÿÿÿ ÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ¿¿¿ ÿÿÿÿÿÿÿÿÿÿÿ ÿÿ ÿÿÿÿÿÿ ÿÿ ÿ ÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ ¿¿¿ ¿¿¿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿ ÿ ÿÿ ÿÿ ÿ ÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿÿÿÿÿÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿ ÿÿ ÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿÿÿÿ ÿÿ ÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |
\ No newline at end of file |
Index: tags/rel_1_4_rc1/bca/bca_raw/esplo2.raw |
=================================================================== |
--- tags/rel_1_4_rc1/bca/bca_raw/esplo2.raw (revision 1476) |
+++ tags/rel_1_4_rc1/bca/bca_raw/esplo2.raw (nonexistent) |
@@ -1,92 +0,0 @@ |
-ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ " 6 H ``U N 1 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
- ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ#%
-JE(H=!E54" =<`m
-f | |
-q _ 2 " |
---|