Changeset c98e6ee in mainline for kernel/generic/src/proc/thread.c
- Timestamp:
- 2008-07-08T16:05:45Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f93f168
- Parents:
- b7f9087
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/thread.c
rb7f9087 rc98e6ee 673 673 } 674 674 675 676 /** Create new user task with 1 thread from image677 *678 * @param program_addr Address of program executable image.679 * @param name Program name.680 *681 * @return Initialized main thread of the task or NULL on error.682 */683 thread_t *thread_create_program(void *program_addr, char *name)684 {685 as_t *as;686 as_area_t *area;687 unsigned int rc;688 task_t *task;689 uspace_arg_t *kernel_uarg;690 691 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);692 if (kernel_uarg == NULL)693 return NULL;694 695 kernel_uarg->uspace_entry =696 (void *) ((elf_header_t *) program_addr)->e_entry;697 kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;698 kernel_uarg->uspace_thread_function = NULL;699 kernel_uarg->uspace_thread_arg = NULL;700 kernel_uarg->uspace_uarg = NULL;701 702 as = as_create(0);703 if (as == NULL) {704 free(kernel_uarg);705 return NULL;706 }707 708 rc = elf_load((elf_header_t *) program_addr, as);709 if (rc != EE_OK) {710 free(kernel_uarg);711 as_destroy(as);712 return NULL;713 }714 715 /*716 * Create the data as_area.717 */718 area = as_area_create(as,719 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,720 LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS,721 AS_AREA_ATTR_NONE, &anon_backend, NULL);722 if (area == NULL) {723 free(kernel_uarg);724 as_destroy(as);725 return NULL;726 }727 728 task = task_create(as, name);729 if (task == NULL) {730 free(kernel_uarg);731 as_destroy(as);732 return NULL;733 }734 735 /*736 * Create the main thread.737 */738 return thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE,739 "uinit", false);740 }741 742 743 675 /** Update accounting of current thread. 744 676 *
Note:
See TracChangeset
for help on using the changeset viewer.