~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 2006-2009. All Rights Reserved.
5
 
 * 
 
3
 *
 
4
 * Copyright Ericsson AB 2006-2010. All Rights Reserved.
 
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
8
8
 * compliance with the License. You should have received a copy of the
9
9
 * Erlang Public License along with this software. If not, it can be
10
10
 * retrieved online at http://www.erlang.org/.
11
 
 * 
 
11
 *
12
12
 * Software distributed under the License is distributed on an "AS IS"
13
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
 * the License for the specific language governing rights and limitations
15
15
 * under the License.
16
 
 * 
 
16
 *
17
17
 * %CopyrightEnd%
18
18
 */
19
19
 
129
129
{
130
130
    if (ptp->handle) {
131
131
        ASSERT(ptp == handle2task(ptp->handle));
132
 
        erts_smp_atomic_set(ptp->handle, (long) NULL);
 
132
        erts_smp_atomic_set(ptp->handle, (erts_aint_t) NULL);
133
133
    }
134
134
}
135
135
 
138
138
{
139
139
    ptp->handle = pthp;
140
140
    if (pthp) {
141
 
        erts_smp_atomic_set(pthp, (long) ptp);
 
141
        erts_smp_atomic_set(pthp, (erts_aint_t) ptp);
142
142
        ASSERT(ptp == handle2task(ptp->handle));
143
143
    }
144
144
}
568
568
        ErtsRunQueue *xrunq = erts_check_emigration_need(runq, ERTS_PORT_PRIO_LEVEL);
569
569
        if (xrunq) {
570
570
            /* Port emigrated ... */
571
 
            erts_smp_atomic_set(&pp->run_queue, (long) xrunq);
 
571
            erts_smp_atomic_set(&pp->run_queue, (erts_aint_t) xrunq);
572
572
            erts_smp_runq_unlock(runq);
573
573
            runq = xrunq;
574
574
        }
575
575
    }
576
576
#endif
577
577
 
578
 
    ASSERT(!(runq->flags & ERTS_RUNQ_FLG_SUSPENDED));
 
578
    ASSERT(!enq_port || !(runq->flags & ERTS_RUNQ_FLG_SUSPENDED));
579
579
 
580
580
    ASSERT(pp->sched.taskq);
581
581
    ASSERT(ptp);
601
601
        break;
602
602
    }
603
603
 
 
604
#ifndef ERTS_SMP
 
605
    /*
 
606
     * When (!enq_port && !pp->sched.exe_taskq) is true in the smp case,
 
607
     * the port might not be in the run queue. If this is the case, another
 
608
     * thread is in the process of enqueueing the port. This very seldom
 
609
     * occur, but do occur and is a valid scenario. Debug info showing this
 
610
     * enqueue in progress must be introduced before we can enable (modified
 
611
     * versions of these) assertions in the smp case again.
 
612
     */
604
613
#if defined(HARD_DEBUG)
605
614
    if (pp->sched.exe_taskq || enq_port)
606
615
        ERTS_PT_CHK_NOT_IN_PORTQ(runq, pp);
612
621
        ASSERT(pp->sched.prev || runq->ports.start == pp);
613
622
    }
614
623
#endif
 
624
#endif
615
625
 
616
626
    if (!enq_port) {
617
627
        ERTS_PT_CHK_PRES_PORTQ(runq, pp);
 
628
        erts_smp_runq_unlock(runq);
618
629
    }
619
630
    else {
620
631
        enqueue_port(runq, pp);
624
635
            profile_runnable_port(pp, am_active);
625
636
        }
626
637
 
 
638
        erts_smp_runq_unlock(runq);
 
639
 
627
640
        erts_smp_notify_inc_runq(runq);
628
641
    }
629
 
    erts_smp_runq_unlock(runq);
630
642
    return 0;
631
643
}
632
644
 
715
727
    ErtsPortTaskExeBlockData *d = (ErtsPortTaskExeBlockData *) vd;
716
728
    erts_smp_runq_lock(d->runq);
717
729
    if (d->resp)
718
 
        *d->resp = erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks) != (long) 0;
 
730
        *d->resp = (erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks)
 
731
                    != (erts_aint_t) 0);
719
732
}
720
733
 
721
734
/*
736
749
    ErtsPortTask *ptp;
737
750
    int res = 0;
738
751
    int reds = ERTS_PORT_REDS_EXECUTE;
739
 
    long io_tasks_executed = 0;
 
752
    erts_aint_t io_tasks_executed = 0;
740
753
    int fpe_was_unmasked;
741
754
    ErtsPortTaskExeBlockData blk_data = {runq, NULL};
742
755
 
902
915
 
903
916
    *curr_port_pp = NULL;
904
917
 
905
 
    if (pp->sched.taskq) {
 
918
#ifdef ERTS_SMP
 
919
    ASSERT(runq == (ErtsRunQueue *) erts_smp_atomic_read(&pp->run_queue));
 
920
#endif
 
921
 
 
922
    if (!pp->sched.taskq) {
 
923
        ASSERT(pp->sched.exe_taskq);
 
924
        pp->sched.exe_taskq = NULL;
 
925
    }
 
926
    else {
 
927
#ifdef ERTS_SMP
 
928
        ErtsRunQueue *xrunq;
 
929
#endif
 
930
 
906
931
        ASSERT(!(pp->status & ERTS_PORT_SFLGS_DEAD));
907
932
        ASSERT(pp->sched.taskq->first);
908
 
        enqueue_port(runq, pp);
 
933
 
 
934
#ifdef ERTS_SMP
 
935
        xrunq = erts_check_emigration_need(runq, ERTS_PORT_PRIO_LEVEL);
 
936
        if (!xrunq) {
 
937
#endif
 
938
            enqueue_port(runq, pp);
 
939
            ASSERT(pp->sched.exe_taskq);
 
940
            pp->sched.exe_taskq = NULL;
 
941
            /* No need to notify ourselves about inc in runq. */
 
942
#ifdef ERTS_SMP
 
943
        }
 
944
        else {
 
945
            /* Port emigrated ... */
 
946
            erts_smp_atomic_set(&pp->run_queue, (erts_aint_t) xrunq);
 
947
            enqueue_port(xrunq, pp);
 
948
            ASSERT(pp->sched.exe_taskq);
 
949
            pp->sched.exe_taskq = NULL;
 
950
            erts_smp_runq_unlock(xrunq);
 
951
            erts_smp_notify_inc_runq(xrunq);
 
952
        }
 
953
#endif
909
954
        port_was_enqueued = 1;
910
 
 
911
 
        /* 
912
 
           erts_smp_notify_inc_runq();
913
 
 
914
 
         * No need to notify schedulers about the increase in run
915
 
         * queue length since at least this thread, which is a
916
 
         * scheduler, will discover that the port run queue isn't
917
 
         * empty before trying to go to sleep.
918
 
         */
919
955
    }
920
956
 
921
 
    ASSERT(pp->sched.exe_taskq);
922
 
    pp->sched.exe_taskq = NULL;
923
 
 
924
 
    res = erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks) != (long) 0;
 
957
    res = (erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks)
 
958
           != (erts_aint_t) 0);
925
959
 
926
960
    ERTS_PT_CHK_PRES_PORTQ(runq, pp);
927
961
 
939
973
    erts_port_release(pp);
940
974
#else
941
975
    {
942
 
        long refc = erts_smp_atomic_dectest(&pp->refc);
 
976
        erts_aint_t refc;
 
977
        erts_smp_mtx_unlock(pp->lock);
 
978
        refc = erts_smp_atomic_dectest(&pp->refc);
943
979
        ASSERT(refc >= 0);
944
 
        if (refc > 0)
945
 
            erts_smp_mtx_unlock(pp->lock);
946
 
        else {
 
980
        if (refc == 0) {
947
981
            erts_smp_runq_unlock(runq);
948
982
            erts_port_cleanup(pp); /* Might aquire runq lock */
949
983
            erts_smp_runq_lock(runq);
950
 
            res = erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks) != (long) 0;
 
984
            res = (erts_smp_atomic_read(&erts_port_task_outstanding_io_tasks)
 
985
                   != (erts_aint_t) 0);
951
986
        }
952
987
    }
953
988
#endif
1080
1115
    if (!ERTS_PORT_IS_IN_RUNQ(from_rq, prt))
1081
1116
        return ERTS_MIGRATE_FAILED_NOT_IN_RUNQ;
1082
1117
    dequeue_port(from_rq, prt);
1083
 
    erts_smp_atomic_set(&prt->run_queue, (long) to_rq);
 
1118
    erts_smp_atomic_set(&prt->run_queue, (erts_aint_t) to_rq);
1084
1119
    enqueue_port(to_rq, prt);
1085
 
    erts_smp_notify_inc_runq(to_rq);
1086
1120
    return ERTS_MIGRATE_SUCCESS;
1087
1121
}
1088
1122
 
1094
1128
void
1095
1129
erts_port_task_init(void)
1096
1130
{
1097
 
    erts_smp_atomic_init(&erts_port_task_outstanding_io_tasks, (long) 0);
 
1131
    erts_smp_atomic_init(&erts_port_task_outstanding_io_tasks, (erts_aint_t) 0);
1098
1132
    init_port_task_alloc();
1099
1133
    init_port_taskq_alloc();
1100
1134
}