process.c 837 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <stdbool.h>
  2. #include <stddef.h>
  3. #ifndef ZIVUOS_DISABLE_DYNAMIC
  4. #include <malloc.h>
  5. #endif
  6. #include "process.h"
  7. #include "kernel.h"
  8. #include "models.h"
  9. #include "state.h"
  10. #ifndef ZV_ALLOC_STEP
  11. #define ZV_ALLOC_STEP 0x08
  12. #endif
  13. void zv_process_init(zv_process_t *self, zv_worker_t worker) {
  14. self->worker = worker;
  15. self->state = ZV_STATE_CREATED;
  16. self->restorer->updater = (zv_updater_t) 0x00;
  17. self->param->pointer = (void *) 0x00;
  18. #ifndef ZIVUOS_DISABLE_DYNAMIC
  19. self->is_dynamic = false;
  20. #endif
  21. }
  22. #ifndef ZIVUOS_DISABLE_DYNAMIC
  23. zv_process_t * zv_process_create(zv_worker_t worker) {
  24. zv_process_t *self = (zv_process_t *) malloc(sizeof(zv_process_t));
  25. if (self == NULL) {
  26. return NULL;
  27. }
  28. zv_process_init(self, worker);
  29. self->is_dynamic = true;
  30. return self;
  31. }
  32. #endif