From b9005f28f79a71bebe87eeaa88f03dcf22c7fc6f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 11 Sep 2019 13:46:56 +0200 Subject: [PATCH] Update docs links to use version 0.5.2 of spin --- .../second-edition/posts/07-hardware-interrupts/index.md | 2 +- blog/content/second-edition/posts/10-heap-allocation/index.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blog/content/second-edition/posts/07-hardware-interrupts/index.md b/blog/content/second-edition/posts/07-hardware-interrupts/index.md index d934340e..df760189 100644 --- a/blog/content/second-edition/posts/07-hardware-interrupts/index.md +++ b/blog/content/second-edition/posts/07-hardware-interrupts/index.md @@ -107,7 +107,7 @@ pub static PICS: spin::Mutex = We're setting the offsets for the pics to the range 32–47 as we noted above. By wrapping the `ChainedPics` struct in a `Mutex` we are able to get safe mutable access (through the [`lock` method][spin mutex lock]), which we need in the next step. The `ChainedPics::new` function is unsafe because wrong offsets could cause undefined behavior. -[spin mutex lock]: https://docs.rs/spin/0.4.8/spin/struct.Mutex.html#method.lock +[spin mutex lock]: https://docs.rs/spin/0.5.2/spin/struct.Mutex.html#method.lock We can now initialize the 8259 PIC in our `init` function: diff --git a/blog/content/second-edition/posts/10-heap-allocation/index.md b/blog/content/second-edition/posts/10-heap-allocation/index.md index af6bf8b4..cfebc7ae 100644 --- a/blog/content/second-edition/posts/10-heap-allocation/index.md +++ b/blog/content/second-edition/posts/10-heap-allocation/index.md @@ -67,7 +67,7 @@ Apart from the `'static` lifetime, static variables also have the useful propert However, this property of static variables brings a crucial drawback: They are read-only by default. Rust enforces this because a [data race] would occur if e.g. two threads modify a static variable at the same time. The only way to modify a static variable is to encapsulate it in a [`Mutex`] type, which ensures that only a single `&mut` reference exists at any point in time. We already used a `Mutex` for our [static VGA buffer `Writer`][vga mutex]. [data race]: https://doc.rust-lang.org/nomicon/races.html -[`Mutex`]: https://docs.rs/spin/0.5.0/spin/struct.Mutex.html +[`Mutex`]: https://docs.rs/spin/0.5.2/spin/struct.Mutex.html [vga mutex]: ./second-edition/posts/03-vga-text-buffer/index.md#spinlocks ## Dynamic Memory @@ -529,7 +529,7 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty(); The struct is named `LockedHeap` because it uses a [`spin::Mutex`] for synchronization. This is required because multiple threads could access the `ALLOCATOR` static at the same time. As always when using a `Mutex`, we need to be careful to not accidentally cause a deadlock. This means that we shouldn't perform any allocations in interrupt handlers, since they can run at an arbitrary time and might interrupt an in-progress allocation. -[`spin::Mutex`]: https://docs.rs/spin/0.5.0/spin/struct.Mutex.html +[`spin::Mutex`]: https://docs.rs/spin/0.5.2/spin/struct.Mutex.html Setting the `LockedHeap` as global allocator is not enough. The reason is that we use the [`empty`] constructor function, which creates an allocator without any backing memory. Like our dummy allocator, it always returns an error on `alloc`. To fix this, we need to initialize the allocator after creating the heap: