Write a device driver for a character device which implements a simple way of message passing. The kernel maintains a list of messages. To limit memory usage, we impose a limit of 4KB = 4*1024 bytes for each message and also impose a limit of the total number of messages stored in the kernel, which is 1000. Your device driver should perform the following operations: When the module is loaded, the device is created. An empty list of messages is created as well. Removing the module deallocates all messages, removes the list of messages and removes the device. Reading from the device returns one message, and removes this message from the kernel list. If the list of messages is empty, the reader returns -EAGAIN. Writing to the device stores the message in kernel space and adds it to the list if the message is below the maximum size, and the limit of the number of all messages stored in the kernel wouldn't be surpassed with this message. If the message is too big, -EINVAL is returned, and if the limit of the number of all messages was surpassed, -EBUSY is returned. The kernel module which implements this driver must be called charDeviceDriver.ko. You need to ensure that your code deals with multiple attempts at reading and writing at the same time. Moreover, your code should handle several read and write attempts concurrently. Your critical sections should be as short as possible. The reader should obtain the messages in a FIFO (first in first out) manner.     Correctly handle the list of messages correctly handle opening, closing, reading, writing to the device. correctly handle the concurrency correctly handle the memory leak   Answer the question in following structure charDeviceDriver.h and charDeviceDriver.c

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

COM.

Write a device driver for a character device which implements a simple way of message passing. The kernel maintains a list of messages. To limit memory usage, we impose a limit of 4KB = 4*1024 bytes for each message and also impose a limit of the total number of messages stored in the kernel, which is 1000.

Your device driver should perform the following operations:

When the module is loaded, the device is created. An empty list of messages is created as well.

Removing the module deallocates all messages, removes the list of messages and removes the device.

Reading from the device returns one message, and removes this message from the kernel list. If the list of messages is empty, the reader returns -EAGAIN.

Writing to the device stores the message in kernel space and adds it to the list if the message is below the maximum size, and the limit of the number of all messages stored in the kernel wouldn't be surpassed with this message. If the message is too big, -EINVAL is returned, and if the limit of the number of all messages was surpassed, -EBUSY is returned.

The kernel module which implements this driver must be called charDeviceDriver.ko.

You need to ensure that your code deals with multiple attempts at reading and writing at the same time. Moreover, your code should handle several read and write attempts concurrently. Your critical sections should be as short as possible. The reader should obtain the messages in a FIFO (first in first out) manner.

 

 

Correctly handle the list of messages

correctly handle opening, closing, reading, writing to the device.

correctly handle the concurrency

correctly handle the memory leak

 

Answer the question in following structure charDeviceDriver.h and charDeviceDriver.c

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Security Technology
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY