1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
3 years ago
7

Design a kernel module that iterates through all task in the system using the for_each_process() macro. In particular, output th

e task name (known as executable name), state, and process id of each task. (You will probably have to read through the task_struct structure in to obtain the names of these fields.) write this code in the module entry point so that its contents will appear in the kernel log buffer, which can be viewed using the dmesg command. To verify that your code is working correctly, compare the contents of the kernel log buffer with the output of the following command, which lists all tasks in the systemps -el
The two values should be very similar. Because tasks are dynamic, however, it is possible that a few tasks may appear in one listing but not the other.

#include

struct task_struct *task;

for_each_process(task) {
/* on each iteration task points to the next task */
}
The various fields in task_struct can then be displayed as the program loops through the for_each_process() macro.
Computers and Technology
1 answer:
aleksley [76]3 years ago
5 0

Answer:

#include <linux/kernel.h>

#include <linux/module.h>

#include <linux/init.h>

#include <linux/sched/signal.h>

#include <linux/sched.h>

 

 

struct task_struct *task;        /*    Structure defined in sched.h for tasks/processes    */

struct task_struct *task_child;        /*    Structure needed to iterate through task children    */

struct list_head *list;            /*    Structure needed to iterate through the list in each task->children struct    */

 

int iterate_init(void)                    /*    Init Module    */

{

   printk(KERN_INFO "%s","LOADING MODULE\n");    /*    good practice to log when loading/removing modules    */

     

   for_each_process( task ){            /*    for_each_process() MACRO for iterating through each task in the os located in linux\sched\signal.h    */

       printk(KERN_INFO "\nPARENT PID: %d PROCESS: %s STATE: %ld",task->pid, task->comm, task->state);/*    log parent id/executable name/state    */

       list_for_each(list, &task->children){                        /*    list_for_each MACRO to iterate through task->children    */

 

           task_child = list_entry( list, struct task_struct, sibling );    /*    using list_entry to declare all vars in task_child struct    */

     

           printk(KERN_INFO "\nCHILD OF %s[%d] PID: %d PROCESS: %s STATE: %ld",task->comm, task->pid, /*    log child of and child pid/name/state    */

               task_child->pid, task_child->comm, task_child->state);

       }

       printk("-----------------------------------------------------");    /*for aesthetics*/

   }    

     

 

   return 0;

 

}                /*    End of Init Module    */

     

void cleanup_exit(void)        /*    Exit Module    */

{

 

 

   printk(KERN_INFO "%s","REMOVING MODULE\n");

 

}                /*    End of Exit Module    */

 

module_init(iterate_init);    /*    Load Module MACRO    */

module_exit(cleanup_exit);    /*    Remove Module MACRO    */

 

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("ITERAT

You might be interested in
Amy, a project manager, needs to make a plan that ensures consistent delivery of the right message to the right people at the ri
AleksAgata [21]
I would have to say the answer is D.) A communication plan. Hope this helps! :-)
7 0
3 years ago
Guys i keep trying to get in touch with brainly but it says "your request could not be submitted" Can someone please help me ?
Ann [662]
Sure what is your question? It also happened to me too
What grade are you in
7 0
2 years ago
Read 2 more answers
Create a program called "Geometry" Prompt the user for a small decimal number. Prompt the user for a large decimal number. Using
skelet666 [1.2K]

Answer:

In Python:

import random

small = float(input("Small: "))

large = float(input("Large: "))

radius = round(random.uniform(small, large),2)

volume = round(4/3 * 22/7 * radius* radius* radius,2)

print("Radius: "+str(radius))

print("Volume: "+str(volume))

Explanation:

This imports the random module

import random

The next two lunes prompt the user for small and large decimal number

small = float(input("Small: "))

large = float(input("Large: "))

This generates the radius

radius = round(random.uniform(small, large),2)

This calculates the volume

volume = round(4/3 * 22/7 * radius* radius* radius,2)

This prints the generated radius

print("Radius: "+str(radius))

This prints the calculated volume

print("Volume: "+str(volume))

<em>Note that, the radius and the volume were approximated to 2 decimal places. Though, it wasn't stated as part of the program requirement; but it is a good practice.</em>

8 0
3 years ago
The PictureBook class is a subclass of the Book class that has one additional attribute: a String variable named illustrator tha
bulgar [2K]

Answer:s

s

Explanation:

x

8 0
4 years ago
Examine these statements about computer software. Which one is false? a Computer software is a collection of coded instructions.
Gnesinka [82]

Answer:

d Computer software used to control a work cell is fundamentally different to business software.

Explanation:

A computer software used to control a work cell is not fundamentally different from a business software. They are different in terms of what they do or the problem they solve or different coded instructions that the computer executes for each of them or maybe different computer languages and hardware requirements. However they are not different fundamentally as they are both computer programs that are based on computer algorithms and code languages or instructions that the computer executes to solve a particular problem.

7 0
4 years ago
Other questions:
  • Write a short Python function, is_multiple(n, m), that takes two integer values and returns True is n is a multiple of m, that i
    9·1 answer
  • When doing black and white photography, which file format should you use if possible? JPEG TIFF PNG RAW
    11·2 answers
  • 3.24 LAB: Seasons
    13·1 answer
  • (15 POINTS) Integrated Circuits Of Made Up Of _____ That Carry The Electrical Current.
    10·1 answer
  • Write a program that asks the user for several days' temperatures and computes the average temperature for that period and how m
    9·1 answer
  • Quienes son el proyectista y el director de obra en una ICT
    6·1 answer
  • Which of the following terms describes a product that is designed to meet humans’ physical and/or psychological needs?
    12·2 answers
  • n a particular board game, there is exactly one row and it comprises N spaces, numbered 0 through N - 1 from left to right. Ther
    12·1 answer
  • In two to three sentences, define "home row" and explain why it is important.
    6·2 answers
  • What value will the variable x have when the loop executes for the first time?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!