4
* Copyright Ericsson AB 2006-2009. All Rights Reserved.
4
* Copyright Ericsson AB 2006-2010. All Rights Reserved.
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/.
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.
568
568
ErtsRunQueue *xrunq = erts_check_emigration_need(runq, ERTS_PORT_PRIO_LEVEL);
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);
578
ASSERT(!(runq->flags & ERTS_RUNQ_FLG_SUSPENDED));
578
ASSERT(!enq_port || !(runq->flags & ERTS_RUNQ_FLG_SUSPENDED));
580
580
ASSERT(pp->sched.taskq);
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.
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);
624
635
profile_runnable_port(pp, am_active);
638
erts_smp_runq_unlock(runq);
627
640
erts_smp_notify_inc_runq(runq);
629
erts_smp_runq_unlock(runq);
715
727
ErtsPortTaskExeBlockData *d = (ErtsPortTaskExeBlockData *) vd;
716
728
erts_smp_runq_lock(d->runq);
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)
736
749
ErtsPortTask *ptp;
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};
903
916
*curr_port_pp = NULL;
905
if (pp->sched.taskq) {
919
ASSERT(runq == (ErtsRunQueue *) erts_smp_atomic_read(&pp->run_queue));
922
if (!pp->sched.taskq) {
923
ASSERT(pp->sched.exe_taskq);
924
pp->sched.exe_taskq = NULL;
906
931
ASSERT(!(pp->status & ERTS_PORT_SFLGS_DEAD));
907
932
ASSERT(pp->sched.taskq->first);
908
enqueue_port(runq, pp);
935
xrunq = erts_check_emigration_need(runq, ERTS_PORT_PRIO_LEVEL);
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. */
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);
909
954
port_was_enqueued = 1;
912
erts_smp_notify_inc_runq();
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.
921
ASSERT(pp->sched.exe_taskq);
922
pp->sched.exe_taskq = NULL;
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)
926
960
ERTS_PT_CHK_PRES_PORTQ(runq, pp);
939
973
erts_port_release(pp);
942
long refc = erts_smp_atomic_dectest(&pp->refc);
977
erts_smp_mtx_unlock(pp->lock);
978
refc = erts_smp_atomic_dectest(&pp->refc);
943
979
ASSERT(refc >= 0);
945
erts_smp_mtx_unlock(pp->lock);
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)
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;