1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
|
<refentry id="VisualOS-Procesor-Simulation">
<refmeta>
<refentrytitle>Procesor Simulation</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>VISUALOS Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Procesor Simulation</refname><refpurpose>Simulation of the processor</refpurpose>
</refnamediv>
<refsynopsisdiv><title>Synopsis</title>
<synopsis>
typedef <link linkend="simul-data-t">simul_data_t</link>;
typedef <link linkend="simul-io-event-t">simul_io_event_t</link>;
typedef <link linkend="simul-mem-t">simul_mem_t</link>;
typedef <link linkend="event-data-t">event_data_t</link>;
void <link linkend="init-CPU-simulation">init_CPU_simulation</link> (void);
void <link linkend="init-CPU-simulation-in-proc">init_CPU_simulation_in_proc</link> (<link linkend="proc-t">proc_t</link> *proc);
void <link linkend="end-CPU-simulation-in-proc">end_CPU_simulation_in_proc</link> (<link linkend="proc-t">proc_t</link> *proc);
void <link linkend="cpy-CPU-simulation-data">cpy_CPU_simulation_data</link> (<link linkend="simul-data-t">simul_data_t</link> *dest,
<link linkend="simul-data-t">simul_data_t</link> *src);
<link linkend="simul-data-t">simul_data_t</link>* <link linkend="dup-CPU-simulation-data">dup_CPU_simulation_data</link> (<link linkend="simul-data-t">simul_data_t</link> *data);
void <link linkend="free-CPU-simulation-data">free_CPU_simulation_data</link> (<link linkend="simul-data-t">simul_data_t</link> *data);
void <link linkend="free-CPU-proc-simulation-data">free_CPU_proc_simulation_data</link> (<link linkend="proc-t">proc_t</link> *proc);
void <link linkend="next-CPU-simulation-in-proc">next_CPU_simulation_in_proc</link> (<link linkend="proc-t">proc_t</link> *proc);
<link linkend="gint">gint</link> <link linkend="CPU-proc-current-page">CPU_proc_current_page</link> (<link linkend="proc-t">proc_t</link> *proc);
<link linkend="gint">gint</link> <link linkend="CPU-proc-next-page">CPU_proc_next_page</link> (<link linkend="proc-t">proc_t</link> *proc);
<link linkend="gboolean">gboolean</link> <link linkend="CPU-proc-current-page-is-write">CPU_proc_current_page_is_write</link> (<link linkend="proc-t">proc_t</link> *proc);
void <link linkend="fix-simulation-in-proc">fix_simulation_in_proc</link> (<link linkend="proc-t">proc_t</link> *proc);
#define <link linkend="IO-BLOCK-CAPS">IO_BLOCK</link> (event)
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This functions serve to manage the CPU's simulation and it's data structures.
</para>
</refsect1>
<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="simul-data-t">simul_data_t</title>
<programlisting>typedef struct { /* simulation data for a process */
gint start_time; /* time of creation */
gint end_time; /* length of the process */
/* IO properties */
/* this list is never modified until process destruction */
simul_io_event_t *io_events; /* list of all io events */
simul_io_event_t *next_io_event; /* pointer to the next event */
simul_io_event_t *last_io_event; /* pointer to the last event */
/* MEM properties */
simul_mem_t *pages; /* list of memory accesses */
gint n_pages; /* number of memory accesses */
gint cur_access; /* index to the current access */
} simul_data_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="simul-io-event-t">simul_io_event_t</title>
<programlisting>typedef struct { /* data for an IO event */
gint block; /* block to read */
gint time; /* time to read @block */
} simul_io_event_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="simul-mem-t">simul_mem_t</title>
<programlisting>typedef struct { /* data for a page access */
gint8 page; /* page to access */
gint8 write; /* is it a write access? */
} simul_mem_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="event-data-t">event_data_t</title>
<programlisting>typedef struct { /* io event data known by all the code */
gint io_block; /* block to access */
} event_data_t;
</programlisting>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="init-CPU-simulation">init_CPU_simulation ()</title>
<programlisting>void init_CPU_simulation (void);</programlisting>
<para>
Initializes the simulation code.</para>
<para>
</para></refsect2>
<refsect2>
<title><anchor id="init-CPU-simulation-in-proc">init_CPU_simulation_in_proc ()</title>
<programlisting>void init_CPU_simulation_in_proc (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
prepares the data structures for simulation in process <parameter>proc</parameter>.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> process involved.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="end-CPU-simulation-in-proc">end_CPU_simulation_in_proc ()</title>
<programlisting>void end_CPU_simulation_in_proc (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
cleans up simulation data in <parameter>proc</parameter> to prepare it for termination.
</para>
<para>
Note: currently does nothing.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> the process involved.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="cpy-CPU-simulation-data">cpy_CPU_simulation_data ()</title>
<programlisting>void cpy_CPU_simulation_data (<link linkend="simul-data-t">simul_data_t</link> *dest,
<link linkend="simul-data-t">simul_data_t</link> *src);</programlisting>
<para>
Copies the contents of <parameter>src</parameter> into <parameter>dest</parameter>, allocating dynamic memory when
needed.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>dest</parameter> :</entry>
<entry> the target of the copy
</entry></row>
<row><entry align="right"><parameter>src</parameter> :</entry>
<entry> the source for the copy
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="dup-CPU-simulation-data">dup_CPU_simulation_data ()</title>
<programlisting><link linkend="simul-data-t">simul_data_t</link>* dup_CPU_simulation_data (<link linkend="simul-data-t">simul_data_t</link> *data);</programlisting>
<para>
Duplicates a simul_data_t structure.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>data</parameter> :</entry>
<entry> a pointer to the data to be copied
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a pointer to newly allocated memory with the same content of <parameter>data</parameter>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="free-CPU-simulation-data">free_CPU_simulation_data ()</title>
<programlisting>void free_CPU_simulation_data (<link linkend="simul-data-t">simul_data_t</link> *data);</programlisting>
<para>
Frees all dynamic memory asociated to <parameter>data</parameter>, including <parameter>data</parameter> itself.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>data</parameter> :</entry>
<entry> the data to be freed
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="free-CPU-proc-simulation-data">free_CPU_proc_simulation_data ()</title>
<programlisting>void free_CPU_proc_simulation_data (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
Free all simulation related dynamic memory from the <parameter>proc</parameter> structure.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> a pointer to a proc_t structure
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="next-CPU-simulation-in-proc">next_CPU_simulation_in_proc ()</title>
<programlisting>void next_CPU_simulation_in_proc (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
Once the process had an event it prepares the process for its next
event, making it a termination event if necesary.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> the process involved.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="CPU-proc-current-page">CPU_proc_current_page ()</title>
<programlisting><link linkend="gint">gint</link> CPU_proc_current_page (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> the process involved.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the page which <parameter>proc</parameter> is using on this very moment.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="CPU-proc-next-page">CPU_proc_next_page ()</title>
<programlisting><link linkend="gint">gint</link> CPU_proc_next_page (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
Makes the process move to its next memory page and should be called once
for each "clock tick" that <parameter>proc</parameter> is running.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> the process involved.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the new page which the process is using.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="CPU-proc-current-page-is-write">CPU_proc_current_page_is_write ()</title>
<programlisting><link linkend="gboolean">gboolean</link> CPU_proc_current_page_is_write (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
Checks if <parameter>proc</parameter> is writing to memory or only reading.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> the process involved.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> TRUE when <parameter>proc</parameter> is writing to its current page.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="fix-simulation-in-proc">fix_simulation_in_proc ()</title>
<programlisting>void fix_simulation_in_proc (<link linkend="proc-t">proc_t</link> *proc);</programlisting>
<para>
Makes the simulation parameters of a process coherent, prevents: multiple
events at the same time, events after process termination, determines the
next event ...</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>proc</parameter> :</entry>
<entry> process whose simulation data should be fixed.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="IO-BLOCK-CAPS">IO_BLOCK()</title>
<programlisting>#define IO_BLOCK(event) (((event_data_t *)(event.data))->io_block)
</programlisting>
<para>
Extracts the block from a IO event.</para>
<para>
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>event</parameter> :</entry>
<entry> process event.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
</refsect1>
</refentry>
|