hardware.c File Reference

Detection of available hardware resources. More...

`#include "private.h"`

## Functions

void | hardware_threads_set (uint32_t n)
| Set the maximum number of worker threads. More...
uint32_t | hardware_threads_get (void)
| Get the maximum number of worker threads. More...
void | hardware_memlimit_set (uint64_t new_memlimit, bool set_compress, bool set_decompress, bool is_percentage)
uint64_t | hardware_memlimit_get (enum operation_mode mode)
| Get the current memory usage limit for compression or decompression. More...
static void | memlimit_show (const char *str, uint64_t value)
| Helper for hardware_memlimit_show() to print one human-readable info line. More...
void | hardware_memlimit_show (void)
| Display the amount of RAM and memory usage limits and exit. More...
void | hardware_init (void)

## Variables

static uint32_t | threads_max = 1
static uint64_t | memlimit_compress
| Memory usage limit for compression. More...
static uint64_t | memlimit_decompress
| Memory usage limit for decompression. More...
static uint64_t | total_ram
| Total amount of physical RAM. More...

## Detailed Description

Detection of available hardware resources.

## Function Documentation

## hardware_threads_set()

void hardware_threads_set | ( | uint32_t | n | ) |

Set the maximum number of worker threads.

References lzma_cputhreads(), and threads_max.

## hardware_threads_get()

uint32_t hardware_threads_get | ( | void |  | ) |

Get the maximum number of worker threads.

References threads_max.

## hardware_memlimit_set()

void hardware_memlimit_set | ( | uint64_t | new_memlimit,
|  | bool | set_compress,
|  | bool | set_decompress,
|  | bool | is_percentage
| ) |  |

Set the memory usage limit. There are separate limits for compression and decompression (the latter includes also –list), one or both can be set with a single call to this function. Zero indicates resetting the limit back to the defaults. The limit can also be set as a percentage of installed RAM; the percentage must be in the range [1, 100].

Referenced by hardware_init().

## hardware_memlimit_get()

uint64_t hardware_memlimit_get | ( | enum operation_mode | mode | ) |

Get the current memory usage limit for compression or decompression.

Referenced by message_mem_needed().

## memlimit_show()

static void memlimit_show | ( | const char * | str,
|  | uint64_t | value
| ) |  |

static

Helper for hardware_memlimit_show() to print one human-readable info line.

## hardware_memlimit_show()

void hardware_memlimit_show | ( | void |  | ) |

Display the amount of RAM and memory usage limits and exit.

## hardware_init()

void hardware_init | ( | void |  | ) |

Initialize some hardware-specific variables, which are needed by other hardware_* functions.

References hardware_memlimit_set(), lzma_physmem(), and total_ram.

## Variable Documentation

## threads_max

uint32_t threads_max = 1

static

Maximum number of worker threads. This can be set with the –threads=NUM command line option.

Referenced by hardware_threads_get(), and hardware_threads_set().

## memlimit_compress

uint64_t memlimit_compress

static

Memory usage limit for compression.

## memlimit_decompress

uint64_t memlimit_decompress

static

Memory usage limit for decompression.

## total_ram

uint64_t total_ram

static

Total amount of physical RAM.

Referenced by hardware_init().