Changeset 0a8f070 in mainline for uspace/srv


Ignore:
Timestamp:
2019-08-07T02:33:03Z (7 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
fe86d9d
Parents:
103939e
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-08-16 16:04:14)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 02:33:03)
Message:

Create taskman server (extracts task-related operations from naming service)

  • Exploits initial phones connected to spawn parent instead of NS.
  • session_ns changed to session_primary (setup during taskman-loader handshake).
  • Task creation moved from NS to taskman (no clonable services anymore).
  • Other task-related operations implementation is to come (task_retval is temporarily dummy).
  • Async framework: implicit connections — create fibrils for calls that arrived through initial phone.

Conflicts:

abi/include/abi/ipc/methods.h
boot/Makefile.common
uspace/Makefile
uspace/app/trace/ipcp.c
uspace/lib/c/generic/async.c
uspace/lib/c/generic/libc.c
uspace/lib/c/generic/loader.c
uspace/lib/c/generic/ns.c
uspace/lib/c/generic/private/async.h
uspace/lib/c/generic/private/ns.h
uspace/lib/c/generic/task.c
uspace/lib/c/include/async.h
uspace/lib/c/include/ipc/services.h
uspace/lib/c/include/ipc/taskman.h
uspace/lib/c/include/loader/pcb.h
uspace/lib/c/include/ns.h
uspace/srv/loader/main.c
uspace/srv/ns/clonable.c
uspace/srv/ns/ns.c

Location:
uspace/srv
Files:
2 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/main.c

    r103939e r0a8f070  
    3434 *
    3535 * The program loader is a special init binary. Its image is used
    36  * to create a new task upon a @c task_spawn syscall. The syscall
    37  * returns the id of a phone connected to the newly created task.
    38  *
    39  * The caller uses this phone to send the pathname and various other
     36 * to create a new task upon a @c task_spawn syscall. It has a phone connected
     37 * to the caller of te syscall. The formal caller (taskman) performs a
     38 * handshake with loader so that apparent caller can communicate with the
     39 * loader.
     40 *
     41 * The apparent caller uses his phone to send the pathname and various other
    4042 * information to the loader. This is normally done by the C library
    4143 * and completely hidden from applications.
    4244 */
     45
    4346
    4447#include <stdio.h>
     
    4750#include <stddef.h>
    4851#include <ipc/services.h>
    49 #include <ipc/loader.h>
    50 #include <ns.h>
    51 #include <loader/pcb.h>
     52#include <as.h>
     53#include <async.h>
     54#include <elf/elf.h>
     55#include <elf/elf_load.h>
    5256#include <entry_point.h>
    5357#include <errno.h>
    54 #include <async.h>
     58#include <fcntl.h>
     59#include <fibril_synch.h>
     60#include <ipc/loader.h>
     61#include <loader/pcb.h>
    5562#include <str.h>
    56 #include <as.h>
    57 #include <elf/elf.h>
    58 #include <elf/elf_load.h>
     63#include <sys/types.h>
     64#include <taskman.h>
     65#include <unistd.h>
    5966#include <vfs/vfs.h>
    6067#include <vfs/inbox.h>
     
    7380/** The Program control block */
    7481static pcb_t pcb;
     82
     83/** Primary IPC session */
     84static async_sess_t *session_primary = NULL;
    7585
    7686/** Current working directory */
     
    92102/** Used to limit number of connections to one. */
    93103static bool connected = false;
     104
     105/** Ensure synchronization of handshake and connection fibrils. */
     106static bool handshake_complete = false;
     107FIBRIL_MUTEX_INITIALIZE(handshake_mtx);
     108FIBRIL_CONDVAR_INITIALIZE(handshake_cv);
    94109
    95110static void ldr_get_taskid(ipc_call_t *req)
     
    319334        DPRINTF("PCB set.\n");
    320335
     336        pcb.session_primary = session_primary;
     337
    321338        pcb.cwd = cwd;
    322339
     
    373390static void ldr_connection(ipc_call_t *icall, void *arg)
    374391{
     392        /* Wait for handshake */
     393        fibril_mutex_lock(&handshake_mtx);
     394        while (!handshake_complete) {
     395                fibril_condvar_wait(&handshake_cv, &handshake_mtx);
     396        }
     397        fibril_mutex_unlock(&handshake_mtx);
     398
    375399        /* Already have a connection? */
    376400        if (connected) {
     
    428452}
    429453
     454static errno_t ldr_taskman_handshake(void)
     455{
     456        errno_t retval = EOK;
     457
     458        fibril_mutex_lock(&handshake_mtx);
     459        session_primary = taskman_handshake();
     460        if (session_primary == NULL) {
     461                retval = errno;
     462                goto finish;
     463        }
     464
     465        async_sess_t *session_tm = async_session_primary_swap(session_primary);
     466        (void)async_hangup(session_tm);
     467
     468        handshake_complete = true;
     469
     470finish:
     471        fibril_condvar_signal(&handshake_cv);
     472        fibril_mutex_unlock(&handshake_mtx);
     473
     474        return retval;
     475}
     476
    430477/** Program loader main function.
    431478 */
    432479int main(int argc, char *argv[])
    433480{
    434         /* Introduce this task to the NS (give it our task ID). */
    435         task_id_t id = task_get_id();
    436         errno_t rc = ns_intro(id);
    437         if (rc != EOK)
     481        /* Set a handler of incomming connections. */
     482        async_set_fallback_port_handler(ldr_connection, NULL);
     483       
     484        /* Handshake with taskman */
     485        int rc = ldr_taskman_handshake();
     486        if (rc != EOK) {
     487                DPRINTF("Failed taskman handshake (%i).\n", errno);
    438488                return rc;
    439 
    440         /* Register at naming service. */
    441         rc = service_register(SERVICE_LOADER, INTERFACE_LOADER,
    442             ldr_connection, NULL);
    443         if (rc != EOK)
    444                 return rc;
    445 
     489        }
     490
     491        /* Handle client connections */
    446492        async_manager();
    447 
     493        //TODO retval?
     494       
    448495        /* Never reached */
    449496        return 0;
  • uspace/srv/ns/Makefile

    r103939e r0a8f070  
    3535        ns.c \
    3636        service.c \
    37         clonable.c \
    3837        task.c
    3938
  • uspace/srv/ns/ns.c

    r103939e r0a8f070  
    4646#include "ns.h"
    4747#include "service.h"
    48 #include "clonable.h"
    4948#include "task.h"
    5049
     
    6160                 * Client requests to be connected to a service.
    6261                 */
    63                 if (ns_service_is_clonable(service, iface)) {
    64                         ns_clonable_forward(service, iface, icall);
    65                 } else {
    66                         ns_service_forward(service, iface, icall);
    67                 }
    68 
     62                ns_service_forward(service, iface, icall);
    6963                return;
    7064        }
     
    9286                         * Server requests service registration.
    9387                         */
    94                         if (ns_service_is_clonable(service, iface)) {
    95                                 ns_clonable_register(&call);
    96                                 continue;
    97                         } else {
    98                                 retval = ns_service_register(service, iface);
    99                         }
     88                        retval = ns_service_register(service, iface);
    10089
    10190                        break;
     
    116105                        break;
    117106                case NS_RETVAL:
    118                         retval = ns_task_retval(&call);
     107                        // TODO move to taskman
     108                        retval = EOK;
     109                        //retval = ns_task_retval(&call);
    119110                        break;
    120111                default:
     
    140131                return rc;
    141132
    142         rc = ns_clonable_init();
    143         if (rc != EOK)
    144                 return rc;
    145 
    146133        rc = task_init();
    147134        if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.