This repository aims to familiarize users with the design and implementation of static and dynamic libraries using the GNU Toolchain and Linux Software development environment. The activities involve command-line argument handling, implementing a static library (cJSON), and a dynamic library functioning as a plugin.
- Bottini, Franco Nicolas
A C program was designed and implemented to perform the following actions when executed with specific arguments:
- If run with the -s option, it executes Exercise 1 from Lab 2.
- If run with the -a option, it executes Exercise 2 from Lab 2.
The cJSON static library was implemented in the project, enabling:
2.1. If the -j option is added along with the options from point 1, the program uses the cJSON static library and displays the result in JSON format.
A dynamic library was designed and implemented as a plugin, extending options and allowing:
-
Dynamic loading when run with the -d option.
-
Using the cJSON library from point 2 to display information about the filesystems supported by the current kernel (/proc/filesystems).
When a file is opened, the operating system creates an entry representing it and stores information about it. So if there are 100 open files, there will be 100 entries in the OS (somewhere in the kernel). These entries are represented by integer numbers (100, 101, 102). This entry number is the file descriptor, uniquely representing an open file within a process. If a process opens 10 files, its process table will have 10 entries for file descriptors. There are four types of file descriptors: standard input, standard output, standard error, and file descriptor.
4.2. Assuming a user is running process with pid 1212, is it valid to run the following command from a new terminal? % echo “Hello, world.” >> /proc/1212/fd/1
Yes, executing the command is valid. The result will write the message "Hello, world" to the file referenced by the selected file descriptor. If we open two terminal instances and then execute the command in one terminal, referencing the input file descriptor of the other, we can observe how "Hello, world" is written from the first terminal to the second.
In Linux, process or session resource access can be limited. There are two types of limits: hard limits and soft limits. Hard limits are set using superuser privileges and represent the maximum resource availability for any process or session. These cannot be exceeded. On the other hand, soft limits can be used by users or processes to self-limit resource usage, as long as these limits are less than or equal to the imposed hard limit. Thus, a hard limit establishes the upper bound, and soft limits allow users or processes to set self-limits within this bound.