# OS_SaveContext

## Syntax

  `#include <nitro/os.h>`
  `BOOL OS_SaveContext( OSContext* context );`

## Arguments

context | Context

## Return Values

A value of "0" indicates that it will return after the context is stored. A value of "1" indicates that it will return to this function after the context is swapped.

## Description

This function stores the current context in the specified context structure, and is used for swapping context in the thread system.

When the current thread switches to the previously stored context, the execution location is directly after when the context was stored. However, it is unclear in this case whether it is returning from this function after restarting or is returning after only being saving.

For this reason, measures are in place to handle the return value from the `OS_SaveContext` function. The function returns with "0," but "1" is stored as `R0`. By doing so, when the context is swapped, the return value (R0) becomes "1" and this can be distinguished from a function call that only stores.

Refer to `OS_InitContext()` for details.

## See Also

`OS_InitContext, OS_LoadContext, OS_DumpContext
`

## Revision History

2003/12/01 Initial version.

CONFIDENTIAL