---
name: "thread_exit"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/thread_exit"
---

# thread\_exit(9)

abandon current thread context

## NAME

**thread\_exit** – abandon current thread context

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/proc.h\>**

*void*\

**thread\_exit**(*void*);

## DESCRIPTION

The **thread\_exit**() function implements the machine independent prelude to a thread shutdown. It will not return, and will result in a call to [mi\_switch(9)](/mi_switch/9.md) to schedule some other thread.

**thread\_exit**() arranges to free all the resources of the thread, specifically the kernel stack.

To protect the [runqueue(9)](/runqueue/9.md), **thread\_exit**() must be called with the *sched\_lock* mutex held.

## SEE ALSO

[mi\_switch(9)](/mi_switch/9.md), [msleep(9)](/msleep/9.md), [mutex(9)](/mutex/9.md), [runqueue(9)](/runqueue/9.md)
