~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "erl_instrument.h"
40
40
#include "erl_printf_term.h"
41
41
#include "erl_misc_utils.h"
 
42
#include "packet_parser.h"
42
43
 
43
44
#ifdef HIPE
44
45
#include "hipe_mode_switch.h"   /* for hipe_mode_switch_init() */
104
105
                                      * not and/or it is too slow.
105
106
                                      */
106
107
 
107
 
#ifdef ERTS_SMP
108
 
Uint no_of_schedulers;
109
 
#endif
110
 
 
111
108
int erts_modified_timing_level;
112
109
 
 
110
int erts_no_crash_dump = 0;     /* Use -d to suppress crash dump. */
 
111
 
113
112
/*
114
113
 * Other global variables.
115
114
 */
253
252
    erts_init_bif();
254
253
    erts_init_bif_chksum();
255
254
    erts_init_bif_re();
 
255
    erts_init_unicode(); /* after RE to get access to PCRE unicode */
256
256
    erts_delay_trap = erts_export_put(am_erlang, am_delay_trap, 2);
257
257
    erts_late_init_process();
258
258
#if HAVE_ERTS_MSEG
265
265
#ifdef _OSE_
266
266
    erl_sys_init_final();
267
267
#endif
 
268
    packet_parser_init();
268
269
}
269
270
 
270
271
static void
380
381
     */
381
382
 
382
383
    erts_init_empty_process(&parent);
 
384
    erts_smp_proc_lock(&parent, ERTS_PROC_LOCK_MAIN);
383
385
    hp = HAlloc(&parent, argc*2 + 4);
384
386
    args = NIL;
385
387
    for (i = argc-1; i >= 0; i--) {
394
396
 
395
397
    so.flags = 0;
396
398
    (void) erl_create_process(&parent, start_mod, am_start, args, &so);
 
399
    erts_smp_proc_unlock(&parent, ERTS_PROC_LOCK_MAIN);
397
400
    erts_cleanup_empty_process(&parent);
398
401
}
399
402
 
500
503
 
501
504
    erts_fprintf(stderr, "-c         disable continuous date/time correction with\n");
502
505
    erts_fprintf(stderr, "           respect to uptime\n");
 
506
 
 
507
    erts_fprintf(stderr, "-d         don't write a crash dump for internally detected errors\n");
 
508
    erts_fprintf(stderr, "           (halt(String) will still produce a crash dump)\n");
 
509
 
503
510
    erts_fprintf(stderr, "-h number  set minimum heap size in words (default %d)\n",
504
511
               H_DEFAULT_SIZE);
505
512
 
591
598
    main_thread = erts_thr_self();
592
599
#endif
593
600
 
594
 
    erts_init_utils();
595
 
 
596
601
    /*
597
602
     * We need to know the number of schedulers to use before we
598
603
     * can initialize the allocators.
599
604
     */
600
605
#ifdef ERTS_SMP
601
606
    ncpu = erts_no_of_cpus();
602
 
    no_of_schedulers = (Uint) (ncpu > 0 ? ncpu : 1);
 
607
    erts_no_schedulers = (Uint) (ncpu > 0 ? ncpu : 1);
 
608
#else
 
609
    erts_no_schedulers = 1;
603
610
#endif
604
611
    if (argc && argv) {
605
612
        int i = 1;
623
630
                    VERBOSE(DEBUG_SYSTEM,
624
631
                            ("using %d scheduler(s)\n", no));
625
632
#ifdef ERTS_SMP
626
 
                    no_of_schedulers = (Uint) no;
 
633
                    erts_no_schedulers = (Uint) no;
627
634
#endif
628
635
                    break;
629
636
                }
635
642
        }
636
643
    }
637
644
 
638
 
#ifdef ERTS_SMP
639
 
    alloc_opts.no_of_schedulers = (int) no_of_schedulers;
640
 
#endif
641
645
    erts_alloc_init(argc, argv, &alloc_opts); /* Handles (and removes)
642
646
                                                 -M flags. */
643
647
 
 
648
    erts_init_utils(); /* Require allocators */
 
649
 
644
650
#ifdef ERTS_ENABLE_LOCK_CHECK
645
651
    erts_lc_late_init();
646
652
#endif
711
717
             * Erlang 5.3/OTP R9C.
712
718
             *
713
719
             * -S, and -T has been reused in Erlang 5.5/OTP R11B.
 
720
             *
 
721
             * -d has been reused in a patch R12B-4.
714
722
             */
715
723
 
716
724
        case '#' :
809
817
                    ("using minimum heap size %d\n",H_MIN_SIZE));
810
818
            break;
811
819
 
 
820
        case 'd':
 
821
            /*
 
822
             * Never produce crash dumps for internally detected
 
823
             * errors; only produce a core dump. (Generation of
 
824
             * crash dumps is destructive and makes it impossible
 
825
             * to inspect the contents of process heaps in the
 
826
             * core dump.)
 
827
             */
 
828
            erts_no_crash_dump = 1;
 
829
            break;
 
830
 
812
831
        case 'e':
813
832
            /* set maximum number of ets tables */
814
833
            arg = get_arg(argv[i]+2, argv[i+1], &i);
876
895
            (void) get_arg(argv[i]+2, argv[i+1], &i);
877
896
            break;
878
897
 
 
898
        case 's' : /* Reserved for SMP scheduler /Rickard */
 
899
            erts_usage();
 
900
            break;
 
901
 
879
902
        case 'T' :
880
903
            arg = get_arg(argv[i]+2, argv[i+1], &i);
881
904
            errno = 0;
1033
1056
    erl_first_process_otp("otp_ring0", NULL, 0, boot_argc, boot_argv);
1034
1057
 
1035
1058
#ifdef ERTS_SMP
1036
 
    erts_start_schedulers(no_of_schedulers);
 
1059
    erts_start_schedulers();
1037
1060
    /* Let system specific code decide what to do with the main thread... */
1038
1061
    erts_sys_main_thread(); /* May or may not return! */
1039
1062
#else
1146
1169
        erts_mtrace_exit((Uint32) an);
1147
1170
 
1148
1171
    /* Produce an Erlang core dump if error */
1149
 
    if(n > 0 && erts_initialized) erl_crash_dump_v(file,line,fmt,args); 
 
1172
    if (n > 0 && erts_initialized &&
 
1173
        (erts_no_crash_dump == 0 || n == ERTS_DUMP_EXIT)) {
 
1174
        erl_crash_dump_v(file, line, fmt, args); 
 
1175
    }
1150
1176
 
1151
1177
    /* need to reinitialize va_args thing */
1152
1178
    va_end(args);
1189
1215
        erts_mtrace_exit((Uint32) an);
1190
1216
 
1191
1217
    /* Produce an Erlang core dump if error */
1192
 
    if(n > 0 && erts_initialized) erl_crash_dump_v((char*) NULL,0,fmt,args); 
 
1218
    if (n > 0 && erts_initialized &&
 
1219
        (erts_no_crash_dump == 0 || n == ERTS_DUMP_EXIT)) {
 
1220
        erl_crash_dump_v((char*) NULL, 0, fmt, args);
 
1221
    }
1193
1222
 
1194
1223
    /* need to reinitialize va_args thing */
1195
1224
    va_end(args);