Skip to content

Commit 6672760

Browse files
committed
Remove lies about task scheduling
it's 1:1 by default now, and N:M is on its way out
1 parent fdd511d commit 6672760

File tree

1 file changed

+11
-48
lines changed

1 file changed

+11
-48
lines changed

src/doc/reference.md

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,47 +4041,20 @@ let y = x;
40414041
An executing Rust program consists of a tree of tasks. A Rust _task_ consists
40424042
of an entry function, a stack, a set of outgoing communication channels and
40434043
incoming communication ports, and ownership of some portion of the heap of a
4044-
single operating-system process. (We expect that many programs will not use
4045-
channels and ports directly, but will instead use higher-level abstractions
4046-
provided in standard libraries, such as pipes.)
4047-
4048-
Multiple Rust tasks may coexist in a single operating-system process. The
4049-
runtime scheduler maps tasks to a certain number of operating-system threads.
4050-
By default, the scheduler chooses the number of threads based on the number of
4051-
concurrent physical CPUs detected at startup. It's also possible to override
4052-
this choice at runtime. When the number of tasks exceeds the number of threads
4053-
— which is likely — the scheduler multiplexes the tasks onto
4054-
threads.[^mnscheduler]
4055-
4056-
[^mnscheduler]: This is an M:N scheduler, which is known to give suboptimal
4057-
results for CPU-bound concurrency problems. In such cases, running with the
4058-
same number of threads and tasks can yield better results. Rust has M:N
4059-
scheduling in order to support very large numbers of tasks in contexts where
4060-
threads are too resource-intensive to use in large number. The cost of
4061-
threads varies substantially per operating system, and is sometimes quite
4062-
low, so this flexibility is not always worth exploiting.
4044+
single operating-system process.
40634045

40644046
### Communication between tasks
40654047

4066-
Rust tasks are isolated and generally unable to interfere with one another's memory directly,
4067-
except through [`unsafe` code](#unsafe-functions).
4068-
All contact between tasks is mediated by safe forms of ownership transfer,
4069-
and data races on memory are prohibited by the type system.
4070-
4071-
Inter-task communication and co-ordination facilities are provided in the
4072-
standard library. These include:
4073-
4074-
- synchronous and asynchronous communication channels with various
4075-
communication topologies
4076-
- read-only and read-write shared variables with various safe mutual exclusion
4077-
patterns
4078-
- simple locks and semaphores
4079-
4080-
When such facilities carry values, the values are restricted to the [`Send`
4081-
type-kind](#type-kinds). Restricting communication interfaces to this kind
4082-
ensures that no references or managed pointers move between tasks. Thus access
4083-
to an entire data structure can be mediated through its owning "root" value; no
4084-
further locking or copying is required to avoid data races within the
4048+
Rust tasks are isolated and generally unable to interfere with one another's
4049+
memory directly, except through [`unsafe` code](#unsafe-functions). All
4050+
contact between tasks is mediated by safe forms of ownership transfer, and data
4051+
races on memory are prohibited by the type system.
4052+
4053+
When you wish to send data between tasks, the values are restricted to the
4054+
[`Send` type-kind](#type-kinds). Restricting communication interfaces to this
4055+
kind ensures that no references or managed pointers move between tasks. Thus
4056+
access to an entire data structure can be mediated through its owning "root"
4057+
value; no further locking or copying is required to avoid data races within the
40854058
substructure of such a value.
40864059

40874060
### Task lifecycle
@@ -4123,16 +4096,6 @@ A task in the *dead* state cannot transition to other states; it exists only to
41234096
have its termination status inspected by other tasks, and/or to await
41244097
reclamation when the last reference to it drops.
41254098

4126-
### Task scheduling
4127-
4128-
The currently scheduled task is given a finite *time slice* in which to
4129-
execute, after which it is *descheduled* at a loop-edge or similar preemption
4130-
point, and another task within is scheduled, pseudo-randomly.
4131-
4132-
An executing task can yield control at any time, by making a library call to
4133-
`std::task::yield`, which deschedules it immediately. Entering any other
4134-
non-executing state (blocked, dead) similarly deschedules the task.
4135-
41364099
# Runtime services, linkage and debugging
41374100

41384101
The Rust _runtime_ is a relatively compact collection of C++ and Rust code that

0 commit comments

Comments
 (0)