source: rtems/testsuites/sptests/spsize/size.c @ 3235ad9

4.104.114.84.9
Last change on this file since 3235ad9 was 3235ad9, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 23, 1995 at 7:30:23 PM

Support for variable length names added to Object Handler. This supports
both fixed length "raw" names and strings from the API's point of view.

Both inline and macro implementations were tested.

  • 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 <rtems/system.h>
18#include <rtems/config.h>
19#include <rtems/copyrt.h>
20#include <rtems/clock.h>
21#include <rtems/tasks.h>
22#include <rtems/dpmem.h>
23#include <rtems/event.h>
24#include <rtems/extension.h>
25#include <rtems/fatal.h>
26#include <rtems/init.h>
27#include <rtems/intthrd.h>
28#include <rtems/isr.h>
29#include <rtems/intr.h>
30#include <rtems/io.h>
31#include <rtems/message.h>
32#include <rtems/mp.h>
33#include <rtems/mpci.h>
34#include <rtems/part.h>
35#include <rtems/priority.h>
36#include <rtems/ratemon.h>
37#include <rtems/region.h>
38#include <rtems/sem.h>
39#include <rtems/signal.h>
40#include <rtems/sysstate.h>
41#include <rtems/thread.h>
42#include <rtems/timer.h>
43#include <rtems/tod.h>
44#include <rtems/userext.h>
45#include <rtems/wkspace.h>
46#include <rtems/mp.h>
47
48#include <stdlib.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_OVERHEAD       \
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_Information)       +
244
245/*modes.h*/     0                                         +
246
247/*mp.h*/        0                                         +
248
249/*mpci.h*/      (sizeof _MPCI_Remote_blocked_threads)     +
250
251/*mppkt.h*/     0                                         +
252
253/*mptables.h*/  0                                         +
254
255/*msgmp.h*/     0                                         +
256
257/*object.h*/    (sizeof _Objects_Local_node)              +
258
259/*objectmp.h*/  (sizeof _Objects_MP_Inactive_global_objects) +
260
261/*options.h*/   0                                         +
262
263/*part.h*/      (sizeof _Partition_Information)           +
264
265/*partmp.h*/    0                                         +
266
267/*priority.h*/  (sizeof _Priority_Major_bit_map)          +
268                (sizeof _Priority_Bit_map)                +
269
270/*ratemon.h*/   (sizeof _Rate_monotonic_Information)      +
271
272/*region.h*/    (sizeof _Region_Information)              +
273
274/*regionmp.h*/  0                                         +
275
276/*rtems.h*/     /* Not applicable */
277
278/*sem.h*/       (sizeof _Semaphore_Information)           +
279
280/*semmp.h*/     0                                         +
281
282/*signal.h*/    0                                         +
283
284/*signalmp.h*/  0                                         +
285
286/*stack.h*/     0                                         +
287
288/*states.h*/    0                                         +
289
290/*status.h*/    0                                         +
291
292/*system.h*/    (sizeof _CPU_Table)                       +
293
294/*sysstate.h*/  (sizeof _System_state_Current)            +
295
296/*taskmp.h*/    0                                         +
297
298/*tasks.h*/     0                                         +
299
300/*thread.h*/    (sizeof _Thread_Dispatch_disable_level)   +
301                (sizeof _Thread_Ticks_remaining_in_timeslice)   +
302                (sizeof _Thread_Ticks_per_timeslice)      +
303                (sizeof _Thread_Ready_chain)              +
304                (sizeof _Thread_Executing)                +
305                (sizeof _Thread_Heir)                     +
306                (sizeof _Thread_Allocated_fp)             +
307                (sizeof _Thread_Information)              +
308                (sizeof _Thread_BSP_context)              +
309
310/*threadmp.h*/  (sizeof _Thread_MP_Receive)               +
311                (sizeof _Thread_MP_Active_proxies)        +
312                (sizeof _Thread_MP_Inactive_proxies)      +
313
314/*threadq.h*/   0                                         +
315
316/*timer.h*/     (sizeof _Timer_Information)               +
317
318/*tod.h*/       (sizeof _TOD_Current)                     +
319                (sizeof _TOD_Seconds_since_epoch)         +
320                (sizeof _TOD_Ticks_since_boot)            +
321                (sizeof _TOD_Microseconds_per_tick)       +
322                (sizeof _TOD_Ticks_per_second)            +
323                (sizeof _TOD_Seconds_watchdog)            +
324
325/*tqdata.h*/    0                                         +
326
327/*types.h*/     0                                         +
328
329/*userext.h*/   (sizeof _User_extensions_Initial)         +
330                (sizeof _User_extensions_List)            +
331
332/*watchdog.h*/  (sizeof _Watchdog_Ticks_chain)            +
333                (sizeof _Watchdog_Seconds_chain)          +
334                (sizeof _Watchdog_Sync_count)             +
335                (sizeof _Watchdog_Sync_level)             +
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#ifndef RTEMS_UNIX
363                 (sizeof _CPU_Default_gr27) +
364#endif
365                 (sizeof _CPU_Interrupt_stack_low) +
366                 (sizeof _CPU_Interrupt_stack_high);
367#endif
368
369#ifdef m68k
370
371/* cpu.h */
372uninitialized += (sizeof _CPU_Interrupt_stack_low) +
373                 (sizeof _CPU_Interrupt_stack_high);
374
375#endif
376
377#ifdef no_cpu
378
379/* cpu.h */
380uninitialized += (sizeof _CPU_Null_fp_context) +
381                 (sizeof _CPU_Interrupt_stack_low) +
382                 (sizeof _CPU_Interrupt_stack_high) +
383                 (sizeof _CPU_Thread_dispatch_pointer);
384
385#endif
386
387initialized +=
388/*copyrt.h*/    (strlen(_Copyright_Notice)+1)             +
389
390/*sptables.h*/  (sizeof _Configuration_Default_multiprocessing_table)  +
391                (strlen(_RTEMS_version)+1)      +
392                (sizeof _Entry_points)          +
393
394
395/*tod.h*/       (sizeof _TOD_Days_per_month)    +
396                (sizeof _TOD_Days_to_date)      +
397                (sizeof _TOD_Days_since_last_leap_year);
398
399puts( "" );
400#ifdef i960CA
401  print_formula();
402#else
403  if ( mode == 0 ) help_size();
404  else             print_formula();
405#endif
406
407printf( "\n" );
408printf( "RTEMS uninitialized data consumes %d bytes\n", uninitialized );
409printf( "RTEMS intialized data consumes %d bytes\n", initialized );
410
411}
412
413void help_size()
414{
415int c = '\0';
416int break_loop;
417int total_size;
418int task_stacks;
419int interrupt_stack;
420int maximum_tasks, size_tasks;
421int maximum_sems, size_sems;
422int maximum_timers, size_timers;
423int maximum_msgqs, size_msgqs;
424int maximum_msgs, size_msgs_overhead;
425int maximum_regns, size_regns;
426int maximum_parts, size_parts;
427int maximum_ports, size_ports;
428int maximum_periods, size_periods;
429int maximum_extensions, size_extensions;
430int maximum_drvs, size_drvs;
431int maximum_fps, size_fps;
432int maximum_nodes, size_nodes;
433int maximum_gobjs, size_gobjs;
434int maximum_proxies, size_proxies;
435
436total_size = sys_req;    /* Fixed Overhead */
437printf( "What is maximum_tasks? " );
438maximum_tasks = getint();
439size_tasks = PER_TASK * maximum_tasks;
440total_size += size_tasks;
441
442printf( "What is maximum_semaphores? " );
443maximum_sems = getint();
444size_sems = PER_SEMAPHORE * maximum_sems;
445total_size += size_sems;
446
447printf( "What is maximum_timers? " );
448maximum_timers = getint();
449size_timers = PER_TIMER * maximum_timers;
450total_size += size_timers;
451
452printf( "What is maximum_message_queues? " );
453maximum_msgqs = getint();
454size_msgqs = PER_MSGQ * maximum_msgqs;
455total_size += size_msgqs;
456
457printf( "What is maximum_messages? " );
458maximum_msgs = getint();
459size_msgs_overhead = PER_MSG_OVERHEAD * maximum_msgs;
460total_size += size_msgs_overhead;
461
462printf( "What is maximum_regions? " );
463maximum_regns = getint();
464size_regns = PER_REGN * maximum_regns;
465total_size += size_regns;
466
467printf( "What is maximum_partitions? " );
468maximum_parts = getint();
469size_parts = PER_PART * maximum_parts;
470total_size += size_parts;
471
472printf( "What is maximum_ports? " );
473maximum_ports = getint();
474size_ports = PER_PORT * maximum_ports;
475total_size += size_ports;
476
477printf( "What is maximum_periods? " );
478maximum_periods = getint();
479size_periods = PER_PORT * maximum_periods;
480total_size += size_periods;
481
482printf( "What is maximum_extensions? " );
483maximum_extensions = getint();
484size_extensions = PER_EXTENSION * maximum_extensions;
485total_size += size_extensions;
486
487printf( "What is number_of_device_drivers? " );
488maximum_drvs = getint();
489size_drvs = PER_DRV  * maximum_drvs;
490total_size += size_drvs;
491
492printf( "What will be total stack requirement for all tasks? " );
493task_stacks = getint();
494total_size += task_stacks;
495
496printf( "What is the size of the interrupt stack? " );
497interrupt_stack = getint();
498total_size += interrupt_stack;
499
500printf( "How many tasks will be created with the FP flag? " );
501maximum_fps = getint();
502size_fps = PER_FPTASK  * maximum_fps;
503total_size += size_fps;
504
505printf( "Is this a single processor system? " );
506for ( break_loop=0 ; !break_loop; c = getchar() ) {
507  switch ( c ) {
508    case 'Y':  case 'y':
509    case 'N':  case 'n':
510      break_loop = 1;
511      break;
512  }
513}
514printf( "%c\n", c );
515if ( c == 'n' || c == 'N' ) {
516  printf( "What is maximum_nodes? " );
517  maximum_nodes = getint();
518  size_nodes = PER_NODE * maximum_nodes;
519  total_size += size_nodes;
520  printf( "What is maximum_global_objects? " );
521  maximum_gobjs = getint();
522  size_gobjs = PER_GOBJECT * maximum_gobjs;
523  total_size += size_gobjs;
524  printf( "What is maximum_proxies? " );
525  maximum_proxies = getint();
526  size_proxies = PER_PROXY * maximum_proxies;
527  total_size += size_proxies;
528} else {
529  maximum_nodes = 0;
530  size_nodes = PER_NODE * 0;
531  maximum_gobjs = 0;
532  size_gobjs = PER_GOBJECT * 0;
533  maximum_proxies = 0;
534  size_proxies = PER_PROXY * 0;
535}
536
537printf( "\n\n" );
538printf( " ************** EXECUTIVE WORK SPACE REQUIRED **************\n" );
539printf( " Tasks                - %03d * %03d            =  %d\n",
540          maximum_tasks, PER_TASK, size_tasks );
541printf( " Semaphores           - %03d * %03d            =  %d\n",
542          maximum_sems, PER_SEMAPHORE, size_sems );
543printf( " Timers               - %03d * %03d            =  %d\n",
544          maximum_timers, PER_TIMER, size_timers );
545printf( " Msg Queues           - %03d * %03d            =  %d\n",
546          maximum_msgqs, PER_MSGQ, size_msgqs );
547printf( " Messages Overhead    - %03d * %03d            =  %d\n",
548          maximum_msgs, PER_MSG_OVERHEAD, size_msgs_overhead );
549printf( " Regions              - %03d * %03d            =  %d\n",
550          maximum_regns, PER_REGN, size_regns);
551printf( " Partitions           - %03d * %03d            =  %d\n",
552          maximum_parts, PER_PART, size_parts );
553printf( " Periods              - %03d * %03d            =  %d\n",
554          maximum_periods, PER_PERIOD, size_periods );
555printf( " Extensions           - %03d * %03d            =  %d\n",
556          maximum_extensions, PER_EXTENSION, size_extensions );
557printf( " Device Drivers       - %03d * %03d            =  %d\n",
558          maximum_drvs, PER_DRV, size_drvs );
559
560printf( " System Requirements  - %04d                 =  %d\n",
561          sys_req, sys_req );
562
563printf( " Floating Point Tasks - %03d * %03d            =  %d\n",
564          maximum_fps, PER_FPTASK, size_fps );
565printf( " Application Task Stacks -                     =  %d\n",
566          task_stacks );
567printf( " Interrupt Stacks -                            =  %d\n",
568          task_stacks );
569printf( " \n" );
570printf( " Global object tables - %03d * %03d            =  %d\n",
571          maximum_nodes, PER_NODE, size_nodes );
572printf( " Global objects       - %03d * %03d            =  %d\n",
573          maximum_gobjs, PER_GOBJECT, size_gobjs );
574printf( " Proxies              - %03d * %03d            =  %d\n",
575          maximum_proxies, PER_PROXY, size_proxies );
576printf( "\n\n" );
577printf( " TOTAL                                       = %d bytes\n",
578      total_size );
579}
580
581void print_formula()
582{
583printf( " ************** EXECUTIVE WORK SPACE FORMULA **************\n" );
584printf( " Tasks                - maximum_tasks * %d\n",      PER_TASK );
585printf( " Timers               - maximum_timers * %d\n",     PER_TIMER );
586printf( " Semaphores           - maximum_semaphores * %d\n", PER_SEMAPHORE);
587printf( " Message Queues       - maximum_message_queues * %d\n", PER_MSGQ );
588printf( " Messages             -\n");
589printf( " Regions              - maximum_regions * %d\n",    PER_REGN );
590printf( " Partitions           - maximum_partitions * %d\n", PER_PART );
591printf( " Ports                - maximum_ports * %d\n",      PER_PORT );
592printf( " Periods              - maximum_periods * %d\n",    PER_PORT );
593printf( " Extensions           - maximum_extensions * %d\n", PER_EXTENSION );
594printf( " Device Drivers       - number_of_device_drivers * %d\n", PER_DRV);
595printf( " System Requirements  - %d\n",                      sys_req );
596printf( " Floating Point Tasks - FPMASK Tasks * %d\n",       CONTEXT_FP_SIZE );
597printf( " User's Tasks' Stacks -\n" );
598printf( " Interrupt Stack      -\n" );
599printf( " \n" );
600printf( " Global object tables - maximum_nodes * %d\n",          PER_NODE );
601printf( " Global objects       - maximum_global_objects * %d\n", PER_GOBJECT );
602printf( " Proxies              - maximum_proxies * %d\n",        PER_PROXY );
603}
Note: See TracBrowser for help on using the repository browser.