source: rtems/testsuites/sptests/spsize/size.c @ 5250ff39

4.104.114.84.95
Last change on this file since 5250ff39 was 5250ff39, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/95 at 21:06:31

Moved _Thread_Information -> _RTEMS_tasks_Information.

Added a table of object information control blocks.

Modified _Thread_Get so it looks up a thread regardless of which
thread management "entity" (manager, internal, etc) actually "owns" it.

  • 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*/     (sizeof _RTEMS_tasks_Information)         +
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_BSP_context)              +
308
309/*threadmp.h*/  (sizeof _Thread_MP_Receive)               +
310                (sizeof _Thread_MP_Active_proxies)        +
311                (sizeof _Thread_MP_Inactive_proxies)      +
312
313/*threadq.h*/   0                                         +
314
315/*timer.h*/     (sizeof _Timer_Information)               +
316
317/*tod.h*/       (sizeof _TOD_Current)                     +
318                (sizeof _TOD_Seconds_since_epoch)         +
319                (sizeof _TOD_Ticks_since_boot)            +
320                (sizeof _TOD_Microseconds_per_tick)       +
321                (sizeof _TOD_Ticks_per_second)            +
322                (sizeof _TOD_Seconds_watchdog)            +
323
324/*tqdata.h*/    0                                         +
325
326/*types.h*/     0                                         +
327
328/*userext.h*/   (sizeof _User_extensions_Initial)         +
329                (sizeof _User_extensions_List)            +
330
331/*watchdog.h*/  (sizeof _Watchdog_Ticks_chain)            +
332                (sizeof _Watchdog_Seconds_chain)          +
333                (sizeof _Watchdog_Sync_count)             +
334                (sizeof _Watchdog_Sync_level)             +
335
336/*wkspace.h*/   (sizeof _Workspace_Area);
337
338uninitialized = 0;
339
340#ifdef i386
341
342/* cpu.h */
343uninitialized += (sizeof _CPU_Null_fp_context) +
344                 (sizeof _CPU_Interrupt_stack_low) +
345                 (sizeof _CPU_Interrupt_stack_high);
346
347#endif
348
349#ifdef i960
350
351/* cpu.h */
352uninitialized += (sizeof _CPU_Interrupt_stack_low) +
353                 (sizeof _CPU_Interrupt_stack_high);
354
355#endif
356
357#ifdef hppa1_1
358
359/* cpu.h */
360uninitialized += (sizeof _CPU_Null_fp_context) +
361#ifndef RTEMS_UNIX
362                 (sizeof _CPU_Default_gr27) +
363#endif
364                 (sizeof _CPU_Interrupt_stack_low) +
365                 (sizeof _CPU_Interrupt_stack_high);
366#endif
367
368#ifdef m68k
369
370/* cpu.h */
371uninitialized += (sizeof _CPU_Interrupt_stack_low) +
372                 (sizeof _CPU_Interrupt_stack_high);
373
374#endif
375
376#ifdef no_cpu
377
378/* cpu.h */
379uninitialized += (sizeof _CPU_Null_fp_context) +
380                 (sizeof _CPU_Interrupt_stack_low) +
381                 (sizeof _CPU_Interrupt_stack_high) +
382                 (sizeof _CPU_Thread_dispatch_pointer);
383
384#endif
385
386initialized +=
387/*copyrt.h*/    (strlen(_Copyright_Notice)+1)             +
388
389/*sptables.h*/  (sizeof _Configuration_Default_multiprocessing_table)  +
390                (strlen(_RTEMS_version)+1)      +
391                (sizeof _Entry_points)          +
392
393
394/*tod.h*/       (sizeof _TOD_Days_per_month)    +
395                (sizeof _TOD_Days_to_date)      +
396                (sizeof _TOD_Days_since_last_leap_year);
397
398puts( "" );
399#ifdef i960CA
400  print_formula();
401#else
402  if ( mode == 0 ) help_size();
403  else             print_formula();
404#endif
405
406printf( "\n" );
407printf( "RTEMS uninitialized data consumes %d bytes\n", uninitialized );
408printf( "RTEMS intialized data consumes %d bytes\n", initialized );
409
410}
411
412void help_size()
413{
414int c = '\0';
415int break_loop;
416int total_size;
417int task_stacks;
418int interrupt_stack;
419int maximum_tasks, size_tasks;
420int maximum_sems, size_sems;
421int maximum_timers, size_timers;
422int maximum_msgqs, size_msgqs;
423int maximum_msgs, size_msgs_overhead;
424int maximum_regns, size_regns;
425int maximum_parts, size_parts;
426int maximum_ports, size_ports;
427int maximum_periods, size_periods;
428int maximum_extensions, size_extensions;
429int maximum_drvs, size_drvs;
430int maximum_fps, size_fps;
431int maximum_nodes, size_nodes;
432int maximum_gobjs, size_gobjs;
433int maximum_proxies, size_proxies;
434
435total_size = sys_req;    /* Fixed Overhead */
436printf( "What is maximum_tasks? " );
437maximum_tasks = getint();
438size_tasks = PER_TASK * maximum_tasks;
439total_size += size_tasks;
440
441printf( "What is maximum_semaphores? " );
442maximum_sems = getint();
443size_sems = PER_SEMAPHORE * maximum_sems;
444total_size += size_sems;
445
446printf( "What is maximum_timers? " );
447maximum_timers = getint();
448size_timers = PER_TIMER * maximum_timers;
449total_size += size_timers;
450
451printf( "What is maximum_message_queues? " );
452maximum_msgqs = getint();
453size_msgqs = PER_MSGQ * maximum_msgqs;
454total_size += size_msgqs;
455
456printf( "What is maximum_messages? " );
457maximum_msgs = getint();
458size_msgs_overhead = PER_MSG_OVERHEAD * maximum_msgs;
459total_size += size_msgs_overhead;
460
461printf( "What is maximum_regions? " );
462maximum_regns = getint();
463size_regns = PER_REGN * maximum_regns;
464total_size += size_regns;
465
466printf( "What is maximum_partitions? " );
467maximum_parts = getint();
468size_parts = PER_PART * maximum_parts;
469total_size += size_parts;
470
471printf( "What is maximum_ports? " );
472maximum_ports = getint();
473size_ports = PER_PORT * maximum_ports;
474total_size += size_ports;
475
476printf( "What is maximum_periods? " );
477maximum_periods = getint();
478size_periods = PER_PORT * maximum_periods;
479total_size += size_periods;
480
481printf( "What is maximum_extensions? " );
482maximum_extensions = getint();
483size_extensions = PER_EXTENSION * maximum_extensions;
484total_size += size_extensions;
485
486printf( "What is number_of_device_drivers? " );
487maximum_drvs = getint();
488size_drvs = PER_DRV  * maximum_drvs;
489total_size += size_drvs;
490
491printf( "What will be total stack requirement for all tasks? " );
492task_stacks = getint();
493total_size += task_stacks;
494
495printf( "What is the size of the interrupt stack? " );
496interrupt_stack = getint();
497total_size += interrupt_stack;
498
499printf( "How many tasks will be created with the FP flag? " );
500maximum_fps = getint();
501size_fps = PER_FPTASK  * maximum_fps;
502total_size += size_fps;
503
504printf( "Is this a single processor system? " );
505for ( break_loop=0 ; !break_loop; c = getchar() ) {
506  switch ( c ) {
507    case 'Y':  case 'y':
508    case 'N':  case 'n':
509      break_loop = 1;
510      break;
511  }
512}
513printf( "%c\n", c );
514if ( c == 'n' || c == 'N' ) {
515  printf( "What is maximum_nodes? " );
516  maximum_nodes = getint();
517  size_nodes = PER_NODE * maximum_nodes;
518  total_size += size_nodes;
519  printf( "What is maximum_global_objects? " );
520  maximum_gobjs = getint();
521  size_gobjs = PER_GOBJECT * maximum_gobjs;
522  total_size += size_gobjs;
523  printf( "What is maximum_proxies? " );
524  maximum_proxies = getint();
525  size_proxies = PER_PROXY * maximum_proxies;
526  total_size += size_proxies;
527} else {
528  maximum_nodes = 0;
529  size_nodes = PER_NODE * 0;
530  maximum_gobjs = 0;
531  size_gobjs = PER_GOBJECT * 0;
532  maximum_proxies = 0;
533  size_proxies = PER_PROXY * 0;
534}
535
536printf( "\n\n" );
537printf( " ************** EXECUTIVE WORK SPACE REQUIRED **************\n" );
538printf( " Tasks                - %03d * %03d            =  %d\n",
539          maximum_tasks, PER_TASK, size_tasks );
540printf( " Semaphores           - %03d * %03d            =  %d\n",
541          maximum_sems, PER_SEMAPHORE, size_sems );
542printf( " Timers               - %03d * %03d            =  %d\n",
543          maximum_timers, PER_TIMER, size_timers );
544printf( " Msg Queues           - %03d * %03d            =  %d\n",
545          maximum_msgqs, PER_MSGQ, size_msgqs );
546printf( " Messages Overhead    - %03d * %03d            =  %d\n",
547          maximum_msgs, PER_MSG_OVERHEAD, size_msgs_overhead );
548printf( " Regions              - %03d * %03d            =  %d\n",
549          maximum_regns, PER_REGN, size_regns);
550printf( " Partitions           - %03d * %03d            =  %d\n",
551          maximum_parts, PER_PART, size_parts );
552printf( " Periods              - %03d * %03d            =  %d\n",
553          maximum_periods, PER_PERIOD, size_periods );
554printf( " Extensions           - %03d * %03d            =  %d\n",
555          maximum_extensions, PER_EXTENSION, size_extensions );
556printf( " Device Drivers       - %03d * %03d            =  %d\n",
557          maximum_drvs, PER_DRV, size_drvs );
558
559printf( " System Requirements  - %04d                 =  %d\n",
560          sys_req, sys_req );
561
562printf( " Floating Point Tasks - %03d * %03d            =  %d\n",
563          maximum_fps, PER_FPTASK, size_fps );
564printf( " Application Task Stacks -                     =  %d\n",
565          task_stacks );
566printf( " Interrupt Stacks -                            =  %d\n",
567          task_stacks );
568printf( " \n" );
569printf( " Global object tables - %03d * %03d            =  %d\n",
570          maximum_nodes, PER_NODE, size_nodes );
571printf( " Global objects       - %03d * %03d            =  %d\n",
572          maximum_gobjs, PER_GOBJECT, size_gobjs );
573printf( " Proxies              - %03d * %03d            =  %d\n",
574          maximum_proxies, PER_PROXY, size_proxies );
575printf( "\n\n" );
576printf( " TOTAL                                       = %d bytes\n",
577      total_size );
578}
579
580void print_formula()
581{
582printf( " ************** EXECUTIVE WORK SPACE FORMULA **************\n" );
583printf( " Tasks                - maximum_tasks * %d\n",      PER_TASK );
584printf( " Timers               - maximum_timers * %d\n",     PER_TIMER );
585printf( " Semaphores           - maximum_semaphores * %d\n", PER_SEMAPHORE);
586printf( " Message Queues       - maximum_message_queues * %d\n", PER_MSGQ );
587printf( " Messages             -\n");
588printf( " Regions              - maximum_regions * %d\n",    PER_REGN );
589printf( " Partitions           - maximum_partitions * %d\n", PER_PART );
590printf( " Ports                - maximum_ports * %d\n",      PER_PORT );
591printf( " Periods              - maximum_periods * %d\n",    PER_PORT );
592printf( " Extensions           - maximum_extensions * %d\n", PER_EXTENSION );
593printf( " Device Drivers       - number_of_device_drivers * %d\n", PER_DRV);
594printf( " System Requirements  - %d\n",                      sys_req );
595printf( " Floating Point Tasks - FPMASK Tasks * %d\n",       CONTEXT_FP_SIZE );
596printf( " User's Tasks' Stacks -\n" );
597printf( " Interrupt Stack      -\n" );
598printf( " \n" );
599printf( " Global object tables - maximum_nodes * %d\n",          PER_NODE );
600printf( " Global objects       - maximum_global_objects * %d\n", PER_GOBJECT );
601printf( " Proxies              - maximum_proxies * %d\n",        PER_PROXY );
602}
Note: See TracBrowser for help on using the repository browser.