# Porting (/examples/porting)



Bringing LVGL to a new platform means supplying a tick source, a display flush callback that pushes rendered pixels to the panel, and input read callbacks for touch, keypad, or encoder devices. If you run under an RTOS, you also wire the OS primitives (threads, mutexes) through the abstraction layer. The examples here show each hook in isolation so you can port them one at a time.

OS Abstraction Layer (OSAL) [#os-abstraction-layer-osal]

Portable wrappers for OS primitives: threads, mutexes, semaphores, and timers.

Thread-safe counter with OSAL sync [#thread-safe-counter-with-osal-sync]

<LvglExampleBrief>
  Count button clicks from a worker thread using 

  `lv_thread_sync_t`

  .
</LvglExampleBrief>

A button is aligned near the center of the active screen and its
`LV_EVENT_CLICKED` callback signals an `lv_thread_sync_t`. A worker
thread created with `lv_thread_init` at `LV_THREAD_PRIO_MID` creates a
counter label under `lv_lock` / `lv_unlock`, then loops on
`lv_thread_sync_wait`, incrementing a press counter and updating the
label text on each signal. The locking pairs keep label updates safe
across the UI and worker threads.

<LvglExample name="lv_example_osal" path="porting/osal/lv_example_osal" />
