cfe45b6e3e
The newly added --worker-thread-priority can be used by users as an opt-in to set the thread priority / nice value. It is the responsibility of the user to ensure that the process has the right to change the priority to the given value. Failure to set the priority will be fatal. See b/154918152 Change-Id: I3b3791e88b6ddf4fa6e39e4587f7fe1ab4d2312f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150560 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
28 lines
837 B
Dart
28 lines
837 B
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// VMOptions=--worker-thread-priority=12
|
|
|
|
import 'dart:ffi';
|
|
import 'dart:io';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
// Value of "PRIO_PROCESS".
|
|
const int kPrioProcess = 0;
|
|
const int kCurrentThreadId = 0;
|
|
|
|
// int getpriority(int which, id_t who)
|
|
typedef GetPriorityFT = int Function(int which, int who);
|
|
typedef GetPriorityNFT = Int32 Function(Int32 which, Uint32 who);
|
|
|
|
final getPriority = DynamicLibrary.process()
|
|
.lookupFunction<GetPriorityNFT, GetPriorityFT>('getpriority');
|
|
|
|
main(args) {
|
|
if (Platform.isLinux || Platform.isAndroid) {
|
|
Expect.equals(12, getPriority(kPrioProcess, kCurrentThreadId));
|
|
}
|
|
}
|