Changeset bfd1546 in mainline for kernel/generic/src/proc/program.c


Ignore:
Timestamp:
2009-02-15T00:01:06Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08b777e
Parents:
4cac212c
Message:

More elegant way of invoking the loader - as a 'cloneable' service. Task names functionality lost for the time being.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/program.c

    r4cac212c rbfd1546  
    191191/** Syscall for creating a new loader instance from userspace.
    192192 *
    193  * Creates a new task from the program loader image, connects a phone
    194  * to it and stores the phone id into the provided buffer.
    195  *
    196  * @param uspace_phone_id       Userspace address where to store the phone id.
     193 * Creates a new task from the program loader image and sets
     194 * the task name.
     195 *
    197196 * @param name                  Name to set on the new task (typically the same
    198197 *                              as the command used to execute it).
     
    200199 * @return 0 on success or an error code from @ref errno.h.
    201200 */
    202 unative_t sys_program_spawn_loader(int *uspace_phone_id, char *uspace_name,
    203     size_t name_len)
     201unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len)
    204202{
    205203        program_t p;
    206         int fake_id;
    207204        int rc;
    208         int phone_id;
    209205        char namebuf[TASK_NAME_BUFLEN];
    210 
    211         fake_id = 0;
    212 
    213         /* Before we even try creating the task, see if we can write the id */
    214         rc = (unative_t) copy_to_uspace(uspace_phone_id, &fake_id,
    215             sizeof(fake_id));
    216         if (rc != 0)
    217                 return rc;
    218206
    219207        /* Cap length of name and copy it from userspace. */
     
    228216        namebuf[name_len] = '\0';
    229217
    230         /* Allocate the phone for communicating with the new task. */
    231 
    232         phone_id = phone_alloc();
    233         if (phone_id < 0)
    234                 return ELIMIT;
    235 
    236218        /* Spawn the new task. */
    237219
     
    240222                return rc;
    241223
    242         phone_connect(phone_id, &p.task->answerbox);
    243 
    244         /* No need to aquire lock before task_ready() */
    245         rc = (unative_t) copy_to_uspace(uspace_phone_id, &phone_id,
    246             sizeof(phone_id));
    247         if (rc != 0) {
    248                 /* Ooops */
    249                 ipc_phone_hangup(&TASK->phones[phone_id]);
    250                 task_kill(p.task->taskid);
    251                 return rc;
    252         }
    253 
    254224        // FIXME: control the capabilities
    255225        cap_set(p.task, cap_get(TASK));
Note: See TracChangeset for help on using the changeset viewer.