source: rtems/c/src/tests/sptests/spsize/size.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 19.1 KB
Line 
1/*  main
2 *
3 *  This program is run to determine the data space and work space
4 *  requirements of the current version of RTEMS.
5 *
6 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#include <stdlib.h>
18
19#include <rtems/system.h>
20#include <rtems/config.h>
21#include <rtems/copyrt.h>
22#include <rtems/clock.h>
23#include <rtems/tasks.h>
24#include <rtems/dpmem.h>
25#include <rtems/event.h>
26#include <rtems/extension.h>
27#include <rtems/fatal.h>
28#include <rtems/init.h>
29#include <rtems/intthrd.h>
30#include <rtems/isr.h>
31#include <rtems/intr.h>
32#include <rtems/io.h>
33#include <rtems/message.h>
34#include <rtems/mp.h>
35#include <rtems/mpci.h>
36#include <rtems/part.h>
37#include <rtems/priority.h>
38#include <rtems/ratemon.h>
39#include <rtems/region.h>
40#include <rtems/sem.h>
41#include <rtems/signal.h>
42#include <rtems/sysstate.h>
43#include <rtems/thread.h>
44#include <rtems/timer.h>
45#include <rtems/tod.h>
46#include <rtems/userext.h>
47#include <rtems/wkspace.h>
48#include <rtems/mp.h>
49
50/* These are always defined by the executive.
51 *
52 * #include <rtems/copyrt.h>
53 * #include <rtems/tables.h>
54 * #include <rtems/sptables.h>
55 */
56#define  HEAP_OVHD        16    /* wasted heap space per task stack */
57#define  NAME_PTR_SIZE     8    /* size of name and pointer table entries */
58#define  READYCHAINS_SIZE  \
59    ((RTEMS_MAXIMUM_PRIORITY + 1) * sizeof(Chain_Control ))
60
61#define PER_TASK      \
62     (sizeof (Thread_Control) + NAME_PTR_SIZE + HEAP_OVHD)
63#define PER_SEMAPHORE \
64     (sizeof (Semaphore_Control) + NAME_PTR_SIZE)
65#define PER_TIMER     \
66     (sizeof (Timer_Control) + NAME_PTR_SIZE)
67#define PER_MSGQ      \
68     (sizeof (Message_queue_Control) + NAME_PTR_SIZE)
69#define PER_MSG       \
70     (sizeof (Message_queue_Buffer_control))
71#define PER_REGN      \
72     (sizeof (Region_Control) + NAME_PTR_SIZE)
73#define PER_PART      \
74     (sizeof (Partition_Control) + NAME_PTR_SIZE)
75#define PER_PERIOD      \
76     (sizeof (Rate_monotonic_Control) + NAME_PTR_SIZE)
77#define PER_PORT      \
78     (sizeof (Dual_ported_memory_Control) + NAME_PTR_SIZE)
79#define PER_EXTENSION     \
80     (sizeof (Extension_Control) + NAME_PTR_SIZE)
81
82#define PER_DRV       (0)
83#define PER_FPTASK    (CONTEXT_FP_SIZE)
84#define PER_GOBTBL    (sizeof (Chain_Control)*4)
85#define PER_NODE      PER_GOBTBL
86#define PER_GOBJECT   (sizeof (Objects_MP_Control))
87#define PER_PROXY     (sizeof (Thread_Proxy_control))
88
89#if (CPU_ALL_TASKS_ARE_FP == TRUE)
90#define SYSTEM_INITIALIZATION_FP (sizeof( Context_Control_fp ))
91#else
92#define SYSTEM_INITIALIZATION_FP 0
93#endif
94
95#if (CPU_IDLE_TASK_IS_FP == TRUE)
96#define SYSTEM_IDLE_FP (sizeof( Context_Control_fp ))
97#else
98#define SYSTEM_IDLE_FP 0
99#endif
100
101#define SYSTEM_TASKS  \
102    (INTERNAL_THREADS_IDLE_THREAD_STACK_SIZE + \
103     INTERNAL_THREADS_SYSTEM_INITIALIZATION_THREAD_STACK_SIZE + \
104     (2*sizeof(Thread_Control))) + \
105     SYSTEM_INITIALIZATION_FP + \
106     SYSTEM_IDLE_FP
107
108#define rtems_unsigned32 unsigned32
109
110rtems_unsigned32 sys_req;
111
112/* to avoid warnings */
113int puts();
114int printf();
115int getint();
116#undef getchar
117int getchar();
118void help_size();
119void print_formula();
120
121void size_rtems(
122  int mode
123)
124{
125int uninitialized = 0;
126int initialized = 0;
127
128/*
129 *  The following data is allocated for each Manager:
130 *
131 *    + Per Manager Object Information
132 *      - local pointer table
133 *      - local name table
134 *      - the object's control blocks
135 *      - global name chains
136 *
137 *  The following is the data allocate from the RTEMS Workspace Area.
138 *  The order indicates the order in which RTEMS allocates it.
139 *
140 *    + Object MP
141 *      - Global Object CB's
142 *    + Thread
143 *      - Ready Chain
144 *    + Thread MP
145 *      - Proxies Chain
146 *    + Interrupt Manager
147 *      - Interrupt Stack
148 *    + Timer Manager
149 *      - per Manager Object Data
150 *    + Extension Manager
151 *      - per Manager Object Data
152 *    + Message Queue Manager
153 *      - per Manager Object Data
154 *      - Message Buffers
155 *    + Semaphore Manager
156 *      - per Manager Object Data
157 *    + Partition Manager
158 *      - per Manager Object Data
159 *    + Region Manager
160 *      - per Manager Object Data
161 *    + Dual Ported Memory Manager
162 *      - per Manager Object Data
163 *    + Rate Monotonic Manager
164 *      - per Manager Object Data
165 *    + Internal Threads Handler
166 *      - SYSI Thread TCB
167 *      - IDLE Thread TCB
168 *      - SYSI Thread stack
169 *      - SYSI Thread FP area (if CPU requires this)
170 *      - IDLE Thread stack
171 *      - IDLE Thread FP area (if CPU requires this)
172 *
173 *  This does not take into account any CPU dependent alignment requirements.
174 *
175 *  The following calculates the overhead needed by RTEMS from the
176 *  Workspace Area.
177 */
178sys_req = SYSTEM_TASKS     +     /* SYSI and IDLE */
179          NAME_PTR_SIZE    +     /* Task Overhead */
180          READYCHAINS_SIZE +     /* Ready Chains */
181          NAME_PTR_SIZE    +     /* Timer Overhead */
182          NAME_PTR_SIZE    +     /* Semaphore Overhead */
183          NAME_PTR_SIZE    +     /* Message Queue Overhead */
184          NAME_PTR_SIZE    +     /* Region Overhead */
185          NAME_PTR_SIZE    +     /* Partition Overhead */
186          NAME_PTR_SIZE    +     /* Dual-Ported Memory Overhead */
187          NAME_PTR_SIZE    +     /* Rate Monotonic Overhead */
188          NAME_PTR_SIZE    +     /* Extension Overhead */
189          PER_NODE;              /* Extra Gobject Table */
190
191uninitialized =
192/*address.h*/   0                                         +
193
194/*asr.h*/       0                                         +
195
196/*attr.h*/      0                                         +
197
198/*bitfield.h*/  0                                         +
199
200/*chain.h*/     0                                         +
201
202/*clock.h*/     0                                         +
203
204/*config.h*/    (sizeof _Configuration_Table)             +
205                (sizeof _Configuration_MP_table)          +
206                (sizeof _Configuration_MPCI_table)        +
207
208/*context.h*/   (sizeof _Context_Switch_necessary)        +
209
210/*copyrt.h*/    0                                         +
211
212/*dpmem.h*/     (sizeof _Dual_ported_memory_Information)  +
213
214/*event.h*/     (sizeof _Event_Sync)                      +
215
216/*eventmp.h*/   0                                         +
217
218/*eventset.h*/  0                                         +
219
220/*extension.h*/ (sizeof _Extension_Information)           +
221
222/*fatal.h*/     0                                         +
223
224/*heap.h*/      0                                         +
225
226/*init.h*/      0                                         +
227
228/*inthrdmp.h*/  0                                         +
229
230/*intr.h*/      0                                         +
231
232/*intthrd.h*/   (sizeof _Internal_threads_System_initialization_thread) +
233                (sizeof _Internal_threads_Idle_thread)    +
234                (sizeof _Internal_threads_MP_Receive_server_entry)    +
235
236/*io.h*/        (sizeof _IO_Number_of_drivers)            +
237                (sizeof _IO_Driver_address_table)         +
238
239/*isr.h*/       (sizeof _ISR_Nest_level)                  +
240                (sizeof _ISR_Vector_table)                +
241                (sizeof _ISR_Signals_to_thread_executing) +
242
243/*message.h*/   (sizeof _Message_queue_Inactive_messages) +
244                (sizeof _Message_queue_Information)       +
245
246/*modes.h*/     0                                         +
247
248/*mp.h*/        0                                         +
249
250/*mpci.h*/      (sizeof _MPCI_Remote_blocked_threads)     +
251
252/*mppkt.h*/     0                                         +
253
254/*mptables.h*/  0                                         +
255
256/*msgmp.h*/     0                                         +
257
258/*object.h*/    (sizeof _Objects_Local_node)              +
259
260/*objectmp.h*/  (sizeof _Objects_MP_Inactive_global_objects) +
261
262/*options.h*/   0                                         +
263
264/*part.h*/      (sizeof _Partition_Information)           +
265
266/*partmp.h*/    0                                         +
267
268/*priority.h*/  (sizeof _Priority_Major_bit_map)          +
269                (sizeof _Priority_Bit_map)                +
270
271/*ratemon.h*/   (sizeof _Rate_monotonic_Information)      +
272
273/*region.h*/    (sizeof _Region_Information)              +
274
275/*regionmp.h*/  0                                         +
276
277/*rtems.h*/     /* Not applicable */
278
279/*sem.h*/       (sizeof _Semaphore_Information)           +
280
281/*semmp.h*/     0                                         +
282
283/*signal.h*/    0                                         +
284
285/*signalmp.h*/  0                                         +
286
287/*stack.h*/     0                                         +
288
289/*states.h*/    0                                         +
290
291/*status.h*/    0                                         +
292
293/*system.h*/    (sizeof _CPU_Table)                       +
294
295/*sysstate.h*/  (sizeof _System_state_Current)            +
296
297/*taskmp.h*/    0                                         +
298
299/*tasks.h*/     0                                         +
300
301/*thread.h*/    (sizeof _Thread_Dispatch_disable_level)   +
302                (sizeof _Thread_Ticks_remaining_in_timeslice)   +
303                (sizeof _Thread_Ticks_per_timeslice)      +
304                (sizeof _Thread_Ready_chain)              +
305                (sizeof _Thread_Executing)                +
306                (sizeof _Thread_Heir)                     +
307                (sizeof _Thread_Allocated_fp)             +
308                (sizeof _Thread_Information)              +
309                (sizeof _Thread_BSP_context)              +
310
311/*threadmp.h*/  (sizeof _Thread_MP_Receive)               +
312                (sizeof _Thread_MP_Active_proxies)        +
313                (sizeof _Thread_MP_Inactive_proxies)      +
314
315/*threadq.h*/   0                                         +
316
317/*timer.h*/     (sizeof _Timer_Information)               +
318
319/*tod.h*/       (sizeof _TOD_Current)                     +
320                (sizeof _TOD_Seconds_since_epoch)         +
321                (sizeof _TOD_Ticks_since_boot)            +
322                (sizeof _TOD_Microseconds_per_tick)       +
323                (sizeof _TOD_Ticks_per_second)            +
324                (sizeof _TOD_Seconds_watchdog)            +
325
326/*tqdata.h*/    0                                         +
327
328/*types.h*/     0                                         +
329
330/*userext.h*/   (sizeof _User_extensions_Initial)         +
331                (sizeof _User_extensions_List)            +
332
333/*watchdog.h*/  (sizeof _Watchdog_Ticks_chain)            +
334                (sizeof _Watchdog_Seconds_chain)          +
335                (sizeof _Watchdog_Sync)                   +
336
337/*wkspace.h*/   (sizeof _Workspace_Area);
338
339uninitialized = 0;
340
341#ifdef i386
342
343/* cpu.h */
344uninitialized += (sizeof _CPU_Null_fp_context) +
345                 (sizeof _CPU_Interrupt_stack_low) +
346                 (sizeof _CPU_Interrupt_stack_high);
347
348#endif
349
350#ifdef i960
351
352/* cpu.h */
353uninitialized += (sizeof _CPU_Interrupt_stack_low) +
354                 (sizeof _CPU_Interrupt_stack_high);
355
356#endif
357
358#ifdef hppa1_1
359
360/* cpu.h */
361uninitialized += (sizeof _CPU_Null_fp_context) +
362                 (sizeof _CPU_Default_gr27) +
363                 (sizeof _CPU_Interrupt_stack_low) +
364                 (sizeof _CPU_Interrupt_stack_high);
365#endif
366
367#ifdef m68k
368
369/* cpu.h */
370uninitialized += (sizeof _CPU_Interrupt_stack_low) +
371                 (sizeof _CPU_Interrupt_stack_high);
372
373#endif
374
375#ifdef no_cpu
376
377/* cpu.h */
378uninitialized += (sizeof _CPU_Null_fp_context) +
379                 (sizeof _CPU_Interrupt_stack_low) +
380                 (sizeof _CPU_Interrupt_stack_high) +
381                 (sizeof _CPU_Thread_dispatch_pointer);
382
383#endif
384
385initialized +=
386/*copyrt.h*/    (strlen(_Copyright_Notice)+1)             +
387
388/*sptables.h*/  (sizeof _Configuration_Default_multiprocessing_table)  +
389                (strlen(_RTEMS_version)+1)      +
390                (sizeof _Entry_points)          +
391
392
393/*tod.h*/       (sizeof _TOD_Days_per_month)    +
394                (sizeof _TOD_Days_to_date)      +
395                (sizeof _TOD_Days_since_last_leap_year);
396
397puts( "" );
398#ifdef i960CA
399  print_formula();
400#else
401  if ( mode == 0 ) help_size();
402  else             print_formula();
403#endif
404
405printf( "\n" );
406printf( "RTEMS uninitialized data consumes %d bytes\n", uninitialized );
407printf( "RTEMS intialized data consumes %d bytes\n", initialized );
408
409}
410
411void help_size()
412{
413int c = '\0';
414int break_loop;
415int total_size;
416int task_stacks;
417int interrupt_stack;
418int maximum_tasks, size_tasks;
419int maximum_sems, size_sems;
420int maximum_timers, size_timers;
421int maximum_msgqs, size_msgqs;
422int maximum_msgs, size_msgs;
423int maximum_regns, size_regns;
424int maximum_parts, size_parts;
425int maximum_ports, size_ports;
426int maximum_periods, size_periods;
427int maximum_extensions, size_extensions;
428int maximum_drvs, size_drvs;
429int maximum_fps, size_fps;
430int maximum_nodes, size_nodes;
431int maximum_gobjs, size_gobjs;
432int maximum_proxies, size_proxies;
433
434total_size = sys_req;    /* Fixed Overhead */
435printf( "What is maximum_tasks? " );
436maximum_tasks = getint();
437size_tasks = PER_TASK * maximum_tasks;
438total_size += size_tasks;
439
440printf( "What is maximum_semaphores? " );
441maximum_sems = getint();
442size_sems = PER_SEMAPHORE * maximum_sems;
443total_size += size_sems;
444
445printf( "What is maximum_timers? " );
446maximum_timers = getint();
447size_timers = PER_TIMER * maximum_timers;
448total_size += size_timers;
449
450printf( "What is maximum_message_queues? " );
451maximum_msgqs = getint();
452size_msgqs = PER_MSGQ * maximum_msgqs;
453total_size += size_msgqs;
454
455printf( "What is maximum_messages? " );
456maximum_msgs = getint();
457size_msgs = PER_MSG * maximum_msgs;
458total_size += size_msgs;
459
460printf( "What is maximum_regions? " );
461maximum_regns = getint();
462size_regns = PER_REGN * maximum_regns;
463total_size += size_regns;
464
465printf( "What is maximum_partitions? " );
466maximum_parts = getint();
467size_parts = PER_PART * maximum_parts;
468total_size += size_parts;
469
470printf( "What is maximum_ports? " );
471maximum_ports = getint();
472size_ports = PER_PORT * maximum_ports;
473total_size += size_ports;
474
475printf( "What is maximum_periods? " );
476maximum_periods = getint();
477size_periods = PER_PORT * maximum_periods;
478total_size += size_periods;
479
480printf( "What is maximum_extensions? " );
481maximum_extensions = getint();
482size_extensions = PER_EXTENSION * maximum_extensions;
483total_size += size_extensions;
484
485printf( "What is number_of_device_drivers? " );
486maximum_drvs = getint();
487size_drvs = PER_DRV  * maximum_drvs;
488total_size += size_drvs;
489
490printf( "What will be total stack requirement for all tasks? " );
491task_stacks = getint();
492total_size += task_stacks;
493
494printf( "What is the size of the interrupt stack? " );
495interrupt_stack = getint();
496total_size += interrupt_stack;
497
498printf( "How many tasks will be created with the FP flag? " );
499maximum_fps = getint();
500size_fps = PER_FPTASK  * maximum_fps;
501total_size += size_fps;
502
503printf( "Is this a single processor system? " );
504for ( break_loop=0 ; !break_loop; c = getchar() ) {
505  switch ( c ) {
506    case 'Y':  case 'y':
507    case 'N':  case 'n':
508      break_loop = 1;
509      break;
510  }
511}
512printf( "%c\n", c );
513if ( c == 'n' || c == 'N' ) {
514  printf( "What is maximum_nodes? " );
515  maximum_nodes = getint();
516  size_nodes = PER_NODE * maximum_nodes;
517  total_size += size_nodes;
518  printf( "What is maximum_global_objects? " );
519  maximum_gobjs = getint();
520  size_gobjs = PER_GOBJECT * maximum_gobjs;
521  total_size += size_gobjs;
522  printf( "What is maximum_proxies? " );
523  maximum_proxies = getint();
524  size_proxies = PER_PROXY * maximum_proxies;
525  total_size += size_proxies;
526} else {
527  maximum_nodes = 0;
528  size_nodes = PER_NODE * 0;
529  maximum_gobjs = 0;
530  size_gobjs = PER_GOBJECT * 0;
531  maximum_proxies = 0;
532  size_proxies = PER_PROXY * 0;
533}
534
535printf( "\n\n" );
536printf( " ************** EXECUTIVE WORK SPACE REQUIRED **************\n" );
537printf( " Tasks                - %03d * %03d            =  %d\n",
538          maximum_tasks, PER_TASK, size_tasks );
539printf( " Semaphores           - %03d * %03d            =  %d\n",
540          maximum_sems, PER_SEMAPHORE, size_sems );
541printf( " Timers               - %03d * %03d            =  %d\n",
542          maximum_timers, PER_TIMER, size_timers );
543printf( " Msg Queues           - %03d * %03d            =  %d\n",
544          maximum_msgqs, PER_MSGQ, size_msgqs );
545printf( " Messages             - %03d * %03d            =  %d\n",
546          maximum_msgs, PER_MSG, size_msgs );
547printf( " Regions              - %03d * %03d            =  %d\n",
548          maximum_regns, PER_REGN, size_regns);
549printf( " Partitions           - %03d * %03d            =  %d\n",
550          maximum_parts, PER_PART, size_parts );
551printf( " Periods              - %03d * %03d            =  %d\n",
552          maximum_periods, PER_PERIOD, size_periods );
553printf( " Extensions           - %03d * %03d            =  %d\n",
554          maximum_extensions, PER_EXTENSION, size_extensions );
555printf( " Device Drivers       - %03d * %03d            =  %d\n",
556          maximum_drvs, PER_DRV, size_drvs );
557
558printf( " System Requirements  - %04d                 =  %d\n",
559          sys_req, sys_req );
560
561printf( " Floating Point Tasks - %03d * %03d            =  %d\n",
562          maximum_fps, PER_FPTASK, size_fps );
563printf( " Application Task Stacks -                     =  %d\n",
564          task_stacks );
565printf( " Interrupt Stacks -                            =  %d\n",
566          task_stacks );
567printf( " \n" );
568printf( " Global object tables - %03d * %03d            =  %d\n",
569          maximum_nodes, PER_NODE, size_nodes );
570printf( " Global objects       - %03d * %03d            =  %d\n",
571          maximum_gobjs, PER_GOBJECT, size_gobjs );
572printf( " Proxies              - %03d * %03d            =  %d\n",
573          maximum_proxies, PER_PROXY, size_proxies );
574printf( "\n\n" );
575printf( " TOTAL                                       = %d bytes\n",
576      total_size );
577}
578
579void print_formula()
580{
581printf( " ************** EXECUTIVE WORK SPACE FORMULA **************\n" );
582printf( " Tasks                - maximum_tasks * %d\n",      PER_TASK );
583printf( " Timers               - maximum_timers * %d\n",     PER_TIMER );
584printf( " Semaphores           - maximum_semaphores * %d\n", PER_SEMAPHORE);
585printf( " Message Queues       - maximum_message_queues * %d\n", PER_MSGQ );
586printf( " Messages             - maximum_messages * %d\n",   PER_MSG );
587printf( " Regions              - maximum_regions * %d\n",    PER_REGN );
588printf( " Partitions           - maximum_partitions * %d\n", PER_PART );
589printf( " Ports                - maximum_ports * %d\n",      PER_PORT );
590printf( " Periods              - maximum_periods * %d\n",    PER_PORT );
591printf( " Extensions           - maximum_extensions * %d\n", PER_EXTENSION );
592printf( " Device Drivers       - number_of_device_drivers * %d\n", PER_DRV);
593printf( " System Requirements  - %d\n",                      sys_req );
594printf( " Floating Point Tasks - FPMASK Tasks * %d\n",       CONTEXT_FP_SIZE );
595printf( " User's Tasks' Stacks -\n" );
596printf( " Interrupt Stack      -\n" );
597printf( " \n" );
598printf( " Global object tables - maximum_nodes * %d\n",          PER_NODE );
599printf( " Global objects       - maximum_global_objects * %d\n", PER_GOBJECT );
600printf( " Proxies              - maximum_proxies * %d\n",        PER_PROXY );
601}
Note: See TracBrowser for help on using the repository browser.