logo

Crowdly

[BasicOS] Fundamentals in Operating Systems (APVRILLE, Ludovic)

Шукаєте відповіді та рішення тестів для [BasicOS] Fundamentals in Operating Systems (APVRILLE, Ludovic)? Перегляньте нашу велику колекцію перевірених відповідей для [BasicOS] Fundamentals in Operating Systems (APVRILLE, Ludovic) в moodle.eurecom.fr.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

Check all the true claims about the result of the stat command given below.

--

$ stat test

  File: test

  Size: 8811          Blocks: 24         IO Block: 4096   regular file

Device: fd01h/64769d    Inode: 22814078    Links: 1

Access: (0644/-rw-r--r--)  Uid: ( 8003/apvrille)   Gid: (  105/soc_staff)

Access: 2022-09-16 18:10:22.641433749 +0200

Modify: 2022-09-16 18:10:22.625433571 +0200

Change: 2022-09-16 18:10:22.625433571 +0200

 Birth: -

\end{lstlisting}

Переглянути це питання

Processors usually have two executions modes: the kernel mode, and the user mode. Check all the true claims among the following ones.

0%
0%
0%
0%
Переглянути це питання

Check all the true claims about the communication between processes.

0%
0%
Переглянути це питання

Check all the true claims about malloc().

Переглянути це питання
Check all the true claims about compilation of a C program P.

Переглянути це питання

Check the memory sections of processes containing memory dynamically allocated during run time

0%
0%
0%
Переглянути це питання

The following code is taken from the ipc/msg.c file of the Linux Kernel 4.19.225. Check all the true claims that follow.

/**

 * newque - Create a new msg queue

 * @ns: namespace

 * @params: ptr to the structure that contains the key and msgflg

 *

 * Called with msg_ids.rwsem held (writer)

 */

static int newque(struct ipc_namespace *ns, struct ipc_params *params)

{

        struct msg_queue *msq;

        int retval;

        key_t key = params->key;

        int msgflg = params->flg;

        msq = kvmalloc(sizeof(*msq), GFP_KERNEL);

        if (unlikely(!msq))

                return -ENOMEM;

        msq->q_perm.mode = msgflg & S_IRWXUGO;

        msq->q_perm.key = key;

        msq->q_perm.security = NULL;

        retval = security_msg_queue_alloc(&msq->q_perm);

        if (retval) {

                kvfree(msq);

                return retval;

        }

        msq->q_stime = msq->q_rtime = 0;

        msq->q_ctime = ktime_get_real_seconds();

        msq->q_cbytes = msq->q_qnum = 0;

        msq->q_qbytes = ns->msg_ctlmnb;

        msq->q_lspid = msq->q_lrpid = NULL;

        INIT_LIST_HEAD(&msq->q_messages);

        INIT_LIST_HEAD(&msq->q_receivers);

        INIT_LIST_HEAD(&msq->q_senders);

        /* ipc_addid() locks msq upon success. */

        retval = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);

        if (retval < 0) {

                ipc_rcu_putref(&msq->q_perm, msg_rcu_free);

                return retval;

        }

        ipc_unlock_object(&msq->q_perm);

        rcu_read_unlock();

        return msq->q_perm.id;

}

0%
0%
Переглянути це питання

Check all the true claims about brk() and malloc(). To help you, we provide the manul page of brk() below.

--

BRK(2)                                              

Linux Programmer's Manual                                              

BRK(2)

NAME

       brk, sbrk - change data segment size

SYNOPSIS

       #include <unistd.h>

       int brk(void *addr);

       void *sbrk(intptr_t increment);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       brk(), sbrk():

           Since glibc 2.19:

               _DEFAULT_SOURCE ||

                   (_XOPEN_SOURCE >= 500) &&

                   ! (_POSIX_C_SOURCE >= 200112L)

           From glibc 2.12 to 2.19:

               _BSD_SOURCE || _SVID_SOURCE ||

                   (_XOPEN_SOURCE >= 500) &&

                   ! (_POSIX_C_SOURCE >= 200112L)

           Before glibc 2.12:

               _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500

DESCRIPTION

      

brk()  and  sbrk()  change the location of the program break, which

defines the end of the process's data segment (i.e., the

      

program break is the first location after the end of the uninitialized

data segment).  Increasing the program break has  the

       effect of allocating memory to the process; decreasing the break deallocates memory.

      

brk()  sets the end of the data segment to the value specified by addr,

when that value is reasonable, the system has enough

       memory, and the process does not exceed its maximum data size (see setrlimit(2)).

      

sbrk() increments the program's data space by increment bytes.  Calling

sbrk() with an increment of 0 can be  used  to  find

       the current location of the program break.

RETURN VALUE

       On success, brk() returns zero.  On error, -1 is returned, and errno is set to ENOMEM.

      

On  success,  sbrk()  returns  the previous program break.  (If the

break was increased, then this value is a pointer to the

       start of the newly allocated memory).  On error, (void *) -1 is returned, and errno is set to ENOMEM.

CONFORMING TO

       4.3BSD; SUSv1, marked LEGACY in SUSv2, removed in POSIX.1-2001.

NOTES

      

Avoid using brk() and sbrk(): the malloc(3) memory allocation package

is the portable and comfortable way of allocating memory.

       Various systems use various types for the argument of sbrk().  Common are int, ssize_t, ptrdiff_t, intptr_t.

   C library/kernel differences

      

The return value described above for brk() is the behavior provided by

the glibc wrapper function for the Linux brk() system

       call. 

(On most other implementations, the return value from brk() is the same;

this return  value  was  also  specified  in

       SUSv2.)  

However,  the  actual Linux system call returns the new program break on

success.  On failure, the system call re‐

       turns the current

break.  The glibc wrapper function does some work (i.e., checks whether

the new break is less  than  addr)

       to provide the 0 and -1 return values described above.

      

On Linux, sbrk() is implemented as a library function that uses the

brk() system call, and does some internal bookkeeping so

       that it can return the old break value.

SEE ALSO

       execve(2), getrlimit(2), end(3), malloc(3)

COLOPHON

      

This page is part of release 4.16 of the Linux man-pages project.  A

description of the project, information about reporting

       bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.

Linux                                                       

2016-03-15                                                      BRK(2)

Переглянути це питання

The following program has a memory allocation issue. At which loop index will our program generate a segmentation fault?

#include <stdlib.h>

#include <stdio.h>

int main(int argc, char ** argv) {

  char *name;

  long long i;

  name = (char *) (malloc (20 * sizeof (char)));

  for(i=0; i>-1; i++) {

    name[i] = (char)i;

    printf("i=%lld\n", i);

  }

 

}

0%
0%
0%
0%
Переглянути це питання

Does this program always provoke a segmentation fault?

#include <stdlib.h>

int main(int argc, char ** argv) {

  char *name;

  name = (char *) (malloc (20 * sizeof (char)));

  name[22] = 'h';

}

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.eurecom.fr?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!