[][src]Struct sunrise_kernel::process::thread_local_storage::TLSManager

pub struct TLSManager {
    tls_pages: Vec<TLSPage>,
}

TLS allocator

Each process holds a TLSManager in its ProcessStruct.

When a thread is being created, we ask the TLSManager to allocate a TLS for it, and when it dies we give it back to the manager so it can be re-used the next time this process spawns a thread.

When all of its TLS are occupied, the TLSManager will expend its memory by allocating a new page.

Memory leak

The TLSManager will never free the pages it manages, and they are leaked when the TLSManager is dropped. They will become available again after the process dies and its ProcessMemory is freed.

A TLSManager will always be dropped at process's death, at the same time as the ProcessMemory. This prevents a dependency in the order in which the TLSManager and the ProcessMemory are dropped.

Fields

tls_pages: Vec<TLSPage>

Vec of tracked pages. When all slots are occupied, we allocate a new page.

Implementations

impl TLSManager[src]

pub fn allocate_tls(
    &mut self,
    pmemory: &mut ProcessMemory
) -> Result<VirtualAddress, KernelError>
[src]

Allocates a new TLS.

This function will try to re-use free TLSs, and will only allocate when all TLS are in use.

The returned TLS still has to be bzeroed, has it may contain the data of a previous thread.

Error

Fails if the allocation fails.

pub unsafe fn free_tls(&mut self, tls: VirtualAddress)[src]

Mark this TLS as free, so it can be re-used by future spawned thread.

Safety

The TLS will be reassigned, so it must never be used again after calling this function.

Panics

Panics if the TLS is not managed by this TLSManager, doesn't have a valid offset, or is already marked free.

Trait Implementations

impl Debug for TLSManager[src]

impl Default for TLSManager[src]

Auto Trait Implementations

impl RefUnwindSafe for TLSManager

impl Send for TLSManager

impl Sync for TLSManager

impl Unpin for TLSManager

impl UnwindSafe for TLSManager

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.