Skip to content

Commit f943d0e

Browse files
committed
fixup! erts: Fair handover of code permissions to first waiter
1 parent 6eeb6cb commit f943d0e

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

erts/emulator/beam/code_ix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ ErtsCodeIndex erts_staging_code_ix(void);
174174
* Main process lock (only) must be held.
175175
* System thread progress must not be blocked.
176176
* Caller must not already have the code modification or staging permissions.
177-
* Caller is suspended and *must* yield if 0 is returned. */
177+
* Caller is suspended and *must* yield if false is returned. */
178178
bool erts_try_seize_code_load_permission(struct process* c_p);
179179

180-
/** @brief Release code loading permission. Resumes any suspended waiters. */
180+
/** @brief Release code loading permission. Resumes first suspended waiters. */
181181
void erts_release_code_load_permission(void);
182182

183183
/** @brief Try to seize exclusive code staging permission. Needed for code

erts/emulator/test/code_SUITE.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ code_permission(_Config) ->
533533
Tester ! {self(), unlocked}
534534
end,
535535
Locker1 = spawn_link(LockerFun),
536-
{Locker2, MRef2} = spawn_monitor(LockerFun),
537-
{Locker3, MRef3} = spawn_monitor(LockerFun),
536+
{Locker2, MRef2} = spawn_opt(LockerFun,[link,monitor]),
537+
{Locker3, MRef3} = spawn_opt(LockerFun,[link,monitor]),
538538
Locker4 = spawn_link(LockerFun),
539539
Locker5 = spawn_link(LockerFun),
540540

@@ -560,13 +560,15 @@ code_permission(_Config) ->
560560
wait_suspended(Locker5),
561561

562562
%% Test killing process waiting in queue
563+
unlink(Locker3),
563564
exit_signal(Locker3, kill),
564565
{'DOWN', MRef3, process, Locker3, killed} = receive_any(),
565566

566567
Locker1 ! unlock,
567568
{Locker1, unlocked} = receive_any(),
568569

569570
%% Test killing process after lock handover but before getting scheduled
571+
unlink(Locker2),
570572
exit_signal(Locker2, kill),
571573
receive {'DOWN', MRef2, process, Locker2, killed} -> ok end,
572574

@@ -1611,4 +1613,7 @@ run_sys_proc_test(Test, Config) ->
16111613
end.
16121614

16131615
receive_any() ->
1614-
receive M -> M end.
1616+
receive M -> M
1617+
after 10_000 ->
1618+
ct:fail({timeout, receive_any})
1619+
end.

erts/emulator/test/code_SUITE_data/erts_test_sync_tracer.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ static ERL_NIF_TERM nifs_loaded(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg
8484

8585
static ERL_NIF_TERM enabled(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
8686
{
87-
int state_arity;
88-
const ERL_NIF_TERM *state_tuple;
89-
ERL_NIF_TERM value;
9087
ASSERT(argc == 3);
9188

9289
//enif_fprintf(stderr, "erts_test_sync_tracer.enabled(%T, %T, %T)\n",
@@ -145,9 +142,7 @@ static void do_wait_for_sync(ERL_NIF_TERM wait_for)
145142

146143
static ERL_NIF_TERM trace(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
147144
{
148-
const ERL_NIF_TERM traceTag = argv[0];
149145
const ERL_NIF_TERM tracerState = argv[1];
150-
const ERL_NIF_TERM tracee = argv[2];
151146
ErlNifPid to;
152147

153148
ASSERT(argc == 5);
@@ -163,7 +158,7 @@ static ERL_NIF_TERM trace(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
163158

164159
// Sending a message does not work as it will probably be enqueued
165160
// and not sent until we are scheduled out.
166-
//enif_send(env, &to, NULL, enif_make_tuple2(env, tracee, traceTag));
161+
//enif_send(env, &to, NULL, enif_make_tuple2(env, argv[2], argv[0]));
167162

168163
erts_internal_test.ethr_atomic_set(&the_sync, atom_true);
169164
do_wait_for_sync(atom_false);

0 commit comments

Comments
 (0)