# lv_os.h (/api/osal/lv_os_h)



<RelatedHeaders name="lv_os_private.h" isPrivate="false" />

<ApiSummary functions="4" />

Functions [#functions]

<ApiMember kind="function" name="lv_lock" file="osal/lv_os.h" line="42" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/osal/lv_os.h#L42">
  lv_lock [#lv_lock]

  Lock LVGL's general mutex. LVGL is not thread safe, so a mutex is used to avoid executing multiple LVGL functions at the same time from different threads. It shall be called when calling LVGL functions from threads different than lv\_timer\_handler's thread. It doesn't need to be called in LVGL events because they are called from <ApiLink name="lv_timer_handler" display="lv_timer_handler()" />. It is called internally in <ApiLink name="lv_timer_handler" display="lv_timer_handler()" />.

  ```c title=" " lineNumbers=1
  void lv_lock(void)
  ```
</ApiMember>

<ApiMember kind="function" name="lv_lock_isr" file="osal/lv_os.h" line="48" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/osal/lv_os.h#L48">
  lv_lock_isr [#lv_lock_isr]

  Same as <ApiLink name="lv_lock" display="lv_lock()" /> but can be called from an interrupt.

  ```c title=" " lineNumbers=1
  lv_result_t lv_lock_isr(void)
  ```

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: success; LV\_RESULT\_INVALID: failure
</ApiMember>

<ApiMember kind="function" name="lv_unlock" file="osal/lv_os.h" line="55" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/osal/lv_os.h#L55">
  lv_unlock [#lv_unlock]

  The pair of <ApiLink name="lv_lock" display="lv_lock()" /> and <ApiLink name="lv_lock_isr" display="lv_lock_isr()" />. It unlocks LVGL general mutex. It is called internally in <ApiLink name="lv_timer_handler" display="lv_timer_handler()" />.

  ```c title=" " lineNumbers=1
  void lv_unlock(void)
  ```
</ApiMember>

<ApiMember kind="function" name="lv_sleep_ms" file="osal/lv_os.h" line="61" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/osal/lv_os.h#L61">
  lv_sleep_ms [#lv_sleep_ms]

  Sleeps the current thread by an amount of milliseconds.

  ```c title=" " lineNumbers=1
  void lv_sleep_ms(uint32_t ms)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type                        | Description                                         |
  | ---- | --------------------------- | --------------------------------------------------- |
  | `ms` | <ApiLink name="uint32_t" /> | amount of milliseconds to sleep the current thread. |
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_linux.h&#x22;, &#x22;lv_os_private.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;]" />
