This document discusses various concepts related to file input/output (I/O) in Linux system programming. It covers opening, reading from, writing to, closing, seeking within, and truncating files using system calls like open(), read(), write(), close(), lseek(), ftruncate(). It also discusses related topics like file descriptors, blocking vs non-blocking I/O, synchronized I/O, direct I/O, and positional reads/writes.
Lesson 2 Understanding Linux File SystemSadia Bashir
Â
The document provides an overview of Linux file systems and file types. It discusses:
1) The main types of files in Linux including directories, special files, links, sockets and pipes.
2) The standard Linux directory structure and the purpose of directories like /bin, /sbin, /etc, and /usr.
3) Common Linux file extensions and hidden files that begin with a dot.
4) Environment variables and how they can be used to customize a system.
5) Symbolic links and how they create references to files without copying the actual file.
Linux uses a preemptive multilevel feedback queue scheduling algorithm. Processes have both static priorities based on nice values and dynamic priorities based on recent CPU usage. The scheduler selects from two lists of active and expired processes using their dynamic priorities. It also performs load balancing across CPU runqueues to improve performance on multiprocessor systems. System calls like setpriority(), sched_setscheduler(), and sched_yield() allow modifying process priorities and scheduling policies.
The document discusses key concepts related to process management in Linux, including process lifecycle, states, memory segments, scheduling, and priorities. It explains that a process goes through creation, execution, termination, and removal phases repeatedly. Process states include running, stopped, interruptible, uninterruptible, and zombie. Process memory is made up of text, data, BSS, heap, and stack segments. Linux uses a O(1) CPU scheduling algorithm that scales well with process and processor counts.
The document provides an introduction to Linux and device drivers. It discusses Linux directory structure, kernel components, kernel modules, character drivers, and registering drivers. Key topics include dynamically loading modules, major and minor numbers, private data, and communicating with hardware via I/O ports and memory mapping.
The document discusses various inter-process communication (IPC) mechanisms in Linux including pipes, FIFOs, messages, shared memory, and sockets. It provides detailed explanations of how pipes and FIFOs are implemented in the Linux kernel, including how they are created, read from, and written to via system calls. It also summarizes the use of System V IPC features like semaphores, messages, and shared memory for communication between processes.
This PPT shares some information on what is booting process and different stages in it. Importance of BIOS and BootROM. Steps involved for loading kernel into RAM. What is the importance of init RAM disk (initrd), when 1st user space application is started and who will create init process.
The document discusses process management in Linux, including scheduling, context switching, and real-time systems. It defines process scheduling as determining which ready process moves to the running state, with the goal of keeping the CPU busy and minimizing response times. Context switching is described as storing the state of a process when it stops running so the CPU can restore another process's state when it starts running. CPU scheduling decisions occur when a process changes state, such as from running to waiting. Real-time systems must meet strict deadlines, and the document discusses soft and hard real-time systems as well as differences between general purpose, real-time, and embedded operating systems.
Lesson 2 Understanding Linux File SystemSadia Bashir
Â
The document provides an overview of Linux file systems and file types. It discusses:
1) The main types of files in Linux including directories, special files, links, sockets and pipes.
2) The standard Linux directory structure and the purpose of directories like /bin, /sbin, /etc, and /usr.
3) Common Linux file extensions and hidden files that begin with a dot.
4) Environment variables and how they can be used to customize a system.
5) Symbolic links and how they create references to files without copying the actual file.
Linux uses a preemptive multilevel feedback queue scheduling algorithm. Processes have both static priorities based on nice values and dynamic priorities based on recent CPU usage. The scheduler selects from two lists of active and expired processes using their dynamic priorities. It also performs load balancing across CPU runqueues to improve performance on multiprocessor systems. System calls like setpriority(), sched_setscheduler(), and sched_yield() allow modifying process priorities and scheduling policies.
The document discusses key concepts related to process management in Linux, including process lifecycle, states, memory segments, scheduling, and priorities. It explains that a process goes through creation, execution, termination, and removal phases repeatedly. Process states include running, stopped, interruptible, uninterruptible, and zombie. Process memory is made up of text, data, BSS, heap, and stack segments. Linux uses a O(1) CPU scheduling algorithm that scales well with process and processor counts.
The document provides an introduction to Linux and device drivers. It discusses Linux directory structure, kernel components, kernel modules, character drivers, and registering drivers. Key topics include dynamically loading modules, major and minor numbers, private data, and communicating with hardware via I/O ports and memory mapping.
The document discusses various inter-process communication (IPC) mechanisms in Linux including pipes, FIFOs, messages, shared memory, and sockets. It provides detailed explanations of how pipes and FIFOs are implemented in the Linux kernel, including how they are created, read from, and written to via system calls. It also summarizes the use of System V IPC features like semaphores, messages, and shared memory for communication between processes.
This PPT shares some information on what is booting process and different stages in it. Importance of BIOS and BootROM. Steps involved for loading kernel into RAM. What is the importance of init RAM disk (initrd), when 1st user space application is started and who will create init process.
The document discusses process management in Linux, including scheduling, context switching, and real-time systems. It defines process scheduling as determining which ready process moves to the running state, with the goal of keeping the CPU busy and minimizing response times. Context switching is described as storing the state of a process when it stops running so the CPU can restore another process's state when it starts running. CPU scheduling decisions occur when a process changes state, such as from running to waiting. Real-time systems must meet strict deadlines, and the document discusses soft and hard real-time systems as well as differences between general purpose, real-time, and embedded operating systems.
U-Boot is an open source boot loader that initializes hardware and loads operating systems. It supports many CPUs and boards. The boot process involves a pre-relocation phase where U-Boot initializes hardware and copies itself to RAM, and a post-relocation phase where it finishes hardware initialization and loads the kernel or operating system. Debugging can be done before and after relocation by setting breakpoints and examining memory.
A brief overview of linux scheduler, context switch , priorities and scheduling classes as well as new features. Also provides an overview of preemption models in linux and how to use each model. all the examples are taken from http://www.discoversdk.com
The document discusses Linux file systems and input/output. It describes the basic structure of Linux file systems, including the root directory and common file system types like Ext4, XFS, and Btrfs. It also summarizes the different classes of devices in Linux - block devices, character devices, and network devices. Block devices provide access to storage and allow random access to fixed sized blocks. Character devices process data sequentially and include keyboards and printers. Network devices operate indirectly through sockets, protocols, and network drivers.
This document discusses Linux kernel crash capture and analysis. It begins with an overview of what constitutes a kernel crash and reasons crashes may occur, both from hardware and software issues. It then covers using kdump to capture virtual memory cores (vmcores) when a crash happens, and configuring kdump for optimal core collection. Finally, it discusses analyzing vmcores after collection using the crash utility, including commands to inspect system information, backtraces, logs, and more.
The document discusses kernel, modules, and drivers in Linux. It provides an introduction to the Linux kernel, explaining what it is and its main functions. It then covers compiling the Linux kernel from source, including downloading the source code, configuring options, and compiling and installing the new kernel. It also discusses working with the GRUB 2 boot loader, including making temporary and persistent changes to the boot menu.
Part 02 Linux Kernel Module ProgrammingTushar B Kute
Â
Presentation on "Linux Kernel Module Programming".
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Linux Kernel Booting Process (1) - For NLKBshimosawa
Â
Describes the bootstrapping part in Linux and some related technologies.
This is the part one of the slides, and the succeeding slides will contain the errata for this slide.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
This document provides an introduction to POSIX threads (Pthreads) programming. It discusses what threads are, how they differ from processes, and how Pthreads provide a standardized threading interface for UNIX systems. The key benefits of Pthreads for parallel programming are improved performance from overlapping CPU and I/O work and priority-based scheduling. Pthreads are well-suited for applications that can break work into independent tasks or respond to asynchronous events. The document outlines common threading models and emphasizes that programmers are responsible for synchronizing access to shared memory in multithreaded programs.
Linux Memory Management with CMA (Contiguous Memory Allocator)Pankaj Suryawanshi
Â
Fundamentals of Linux Memory Management and CMA (Contiguous Memory Allocator) In Linux.
Virtual Memory, Physical Memory, Swap Space, DMA, IOMMU, Paging, Segmentation, TLB, Hugepages, Ion google memory manager
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...Adrian Huang
Â
This document describes setting up a QEMU virtual machine with Ubuntu 20.04.1 to debug Linux kernel code using gdb. It has a 2-socket CPU configuration with 16GB of memory and disabled KASAN and ASLR. The QEMU VM can be used to run sample code and observe Linux kernel behavior under gdb, such as setting conditional breakpoints to analyze page fault behavior for mmap addresses by referencing a gdb debugging text file.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
Unix , Linux Commands
Unix, which is not an acronym, was developed by some of the members of the Multics team at the bell labs starting in the late 1960's by many of the same people who helped create the C programming language.
This document discusses UNIX signal programming and functions in the signal.h header file. It provides examples of how to use the signal() function to install new signal handlers and handle multiple signals. It also describes how to raise signals from a process using the raise() system call and how to send signals to other processes using the kill() system call. The document explains that when a signal is received, like Control-C, it will terminate the process and any child processes since they are members of the same process group.
The document summarizes Linux memory management architecture. It has two parts - an architecture independent memory model and implementation for a specific architecture. The memory model divides virtual address space into pages and uses page tables to map virtual to physical addresses. It also describes data structures like page table entries and region descriptors that track memory mappings.
1. Process management is an integral part of operating systems for allocating resources, enabling information sharing, and protecting processes. The OS maintains data structures describing each process's state and resource ownership.
2. Processes go through discrete states and events can cause state changes. Scheduling selects processes to run from ready, device, and job queues using algorithms like round robin, shortest job first, and priority scheduling.
3. CPU scheduling aims to maximize utilization and throughput while minimizing waiting times using criteria like response time, turnaround time, and fairness between processes.
This document discusses Linux kernel debugging. It provides an overview of debugging techniques including collecting system information, handling failures, and using printk(), KGDB, and debuggers. Key points covered are the components of a debugger, how KGDB can be used with gdb to debug interactively, analyzing crash data, and some debugging tricks and print functions.
Linux device drivers act as an interface between hardware devices and user programs. They communicate with hardware devices and expose an interface to user applications through system calls. Device drivers can be loaded as kernel modules and provide access to devices through special files in the /dev directory. Common operations for drivers include handling read and write requests either through interrupt-driven or polling-based I/O.
This presentation covers the understanding of system calls for various resource management and covers system calls for file management in details. The understanding of using system calls helps to start with working with device driver programming on Unix/Linux OS.
This document provides an overview of file I/O and systems programming in UNIX. It discusses file descriptors, opening and accessing files, file permissions, file systems, linking and renaming files, and password files. The key points covered are:
- Files are accessed using file descriptors rather than FILE objects.
- Common file access functions include open(), close(), read(), write(), and lseek().
- Each open file has a v-node containing metadata and pointers to functions for that file type.
- File permissions are checked against a process's effective user and group IDs.
- Directories map filenames to inodes, which contain file metadata and data block pointers.
- Functions for file manipulation include link(), unlink
U-Boot is an open source boot loader that initializes hardware and loads operating systems. It supports many CPUs and boards. The boot process involves a pre-relocation phase where U-Boot initializes hardware and copies itself to RAM, and a post-relocation phase where it finishes hardware initialization and loads the kernel or operating system. Debugging can be done before and after relocation by setting breakpoints and examining memory.
A brief overview of linux scheduler, context switch , priorities and scheduling classes as well as new features. Also provides an overview of preemption models in linux and how to use each model. all the examples are taken from http://www.discoversdk.com
The document discusses Linux file systems and input/output. It describes the basic structure of Linux file systems, including the root directory and common file system types like Ext4, XFS, and Btrfs. It also summarizes the different classes of devices in Linux - block devices, character devices, and network devices. Block devices provide access to storage and allow random access to fixed sized blocks. Character devices process data sequentially and include keyboards and printers. Network devices operate indirectly through sockets, protocols, and network drivers.
This document discusses Linux kernel crash capture and analysis. It begins with an overview of what constitutes a kernel crash and reasons crashes may occur, both from hardware and software issues. It then covers using kdump to capture virtual memory cores (vmcores) when a crash happens, and configuring kdump for optimal core collection. Finally, it discusses analyzing vmcores after collection using the crash utility, including commands to inspect system information, backtraces, logs, and more.
The document discusses kernel, modules, and drivers in Linux. It provides an introduction to the Linux kernel, explaining what it is and its main functions. It then covers compiling the Linux kernel from source, including downloading the source code, configuring options, and compiling and installing the new kernel. It also discusses working with the GRUB 2 boot loader, including making temporary and persistent changes to the boot menu.
Part 02 Linux Kernel Module ProgrammingTushar B Kute
Â
Presentation on "Linux Kernel Module Programming".
Presented at Army Institute of Technology, Pune for FDP on "Basics of Linux Kernel Programming". by Tushar B Kute (http://tusharkute.com).
Linux Kernel Booting Process (1) - For NLKBshimosawa
Â
Describes the bootstrapping part in Linux and some related technologies.
This is the part one of the slides, and the succeeding slides will contain the errata for this slide.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
This document provides an introduction to POSIX threads (Pthreads) programming. It discusses what threads are, how they differ from processes, and how Pthreads provide a standardized threading interface for UNIX systems. The key benefits of Pthreads for parallel programming are improved performance from overlapping CPU and I/O work and priority-based scheduling. Pthreads are well-suited for applications that can break work into independent tasks or respond to asynchronous events. The document outlines common threading models and emphasizes that programmers are responsible for synchronizing access to shared memory in multithreaded programs.
Linux Memory Management with CMA (Contiguous Memory Allocator)Pankaj Suryawanshi
Â
Fundamentals of Linux Memory Management and CMA (Contiguous Memory Allocator) In Linux.
Virtual Memory, Physical Memory, Swap Space, DMA, IOMMU, Paging, Segmentation, TLB, Hugepages, Ion google memory manager
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...Adrian Huang
Â
This document describes setting up a QEMU virtual machine with Ubuntu 20.04.1 to debug Linux kernel code using gdb. It has a 2-socket CPU configuration with 16GB of memory and disabled KASAN and ASLR. The QEMU VM can be used to run sample code and observe Linux kernel behavior under gdb, such as setting conditional breakpoints to analyze page fault behavior for mmap addresses by referencing a gdb debugging text file.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
Unix , Linux Commands
Unix, which is not an acronym, was developed by some of the members of the Multics team at the bell labs starting in the late 1960's by many of the same people who helped create the C programming language.
This document discusses UNIX signal programming and functions in the signal.h header file. It provides examples of how to use the signal() function to install new signal handlers and handle multiple signals. It also describes how to raise signals from a process using the raise() system call and how to send signals to other processes using the kill() system call. The document explains that when a signal is received, like Control-C, it will terminate the process and any child processes since they are members of the same process group.
The document summarizes Linux memory management architecture. It has two parts - an architecture independent memory model and implementation for a specific architecture. The memory model divides virtual address space into pages and uses page tables to map virtual to physical addresses. It also describes data structures like page table entries and region descriptors that track memory mappings.
1. Process management is an integral part of operating systems for allocating resources, enabling information sharing, and protecting processes. The OS maintains data structures describing each process's state and resource ownership.
2. Processes go through discrete states and events can cause state changes. Scheduling selects processes to run from ready, device, and job queues using algorithms like round robin, shortest job first, and priority scheduling.
3. CPU scheduling aims to maximize utilization and throughput while minimizing waiting times using criteria like response time, turnaround time, and fairness between processes.
This document discusses Linux kernel debugging. It provides an overview of debugging techniques including collecting system information, handling failures, and using printk(), KGDB, and debuggers. Key points covered are the components of a debugger, how KGDB can be used with gdb to debug interactively, analyzing crash data, and some debugging tricks and print functions.
Linux device drivers act as an interface between hardware devices and user programs. They communicate with hardware devices and expose an interface to user applications through system calls. Device drivers can be loaded as kernel modules and provide access to devices through special files in the /dev directory. Common operations for drivers include handling read and write requests either through interrupt-driven or polling-based I/O.
This presentation covers the understanding of system calls for various resource management and covers system calls for file management in details. The understanding of using system calls helps to start with working with device driver programming on Unix/Linux OS.
This document provides an overview of file I/O and systems programming in UNIX. It discusses file descriptors, opening and accessing files, file permissions, file systems, linking and renaming files, and password files. The key points covered are:
- Files are accessed using file descriptors rather than FILE objects.
- Common file access functions include open(), close(), read(), write(), and lseek().
- Each open file has a v-node containing metadata and pointers to functions for that file type.
- File permissions are checked against a process's effective user and group IDs.
- Directories map filenames to inodes, which contain file metadata and data block pointers.
- Functions for file manipulation include link(), unlink
This document provides an overview of streams and file input/output (I/O) in Java. It discusses the differences between text and binary files, and how to read from and write to both types of files using classes like PrintWriter, FileOutputStream, BufferedReader, and FileReader. Key points covered include opening and closing files, reading/writing text with print/println methods, and handling I/O exceptions. The goal is to learn the basic concepts and mechanisms for saving and loading data from files.
The document discusses various UNIX file APIs. It describes different file types in UNIX like regular files, directories, FIFO files, device files, and symbolic links. It then explains the open(), read(), write(), close() system calls used to perform operations on files. open() is used to open or create a file. read() reads data from an open file. write() writes data to a file. close() closes an open file. Examples of using these calls are also provided.
Linux System Programming - Buffered I/O YourHelper1
Â
This document discusses buffered I/O in 3 parts:
1) Introduction to buffered I/O which improves I/O throughput by using buffers to handle speed mismatches between devices and applications. Buffers temporarily store data to reduce high I/O latencies.
2) User-buffered I/O where applications use buffers in user memory to minimize system calls and improve performance. Block sizes are important to align I/O operations.
3) Standard I/O functions like fopen(), fgets(), fputc() which provide platform-independent buffered I/O using file pointers and buffers. Functions allow reading, writing, seeking and flushing data to streams.
1) The document discusses file handling in C++ using fstream. Files allow storing data permanently unlike cin and cout streams.
2) Files can be opened using constructor functions or member functions like open(). open() allows specifying the file mode like read/write.
3) Reading and writing to files can be done using extraction/insertion operators, get()/put(), or read()/write() functions depending on data types. Member functions help check file status and position.
The document provides an overview of the Linux file system structure and common Linux commands. It describes that in Linux, everything is treated as a file, including devices, pipes and directories. It explains the different types of files and partitions in Linux, and provides examples of common file manipulation and system monitoring commands.
The document discusses input and output streams in Java. It provides an overview of character streams, byte streams, and connected streams. It explains how to read from and write to files using FileInputStream, FileOutputStream, FileReader, and FileWriter. It emphasizes the importance of specifying the correct character encoding when working with text files. An example demonstrates reading an image file as bytes, modifying some bytes, and writing the image to a new file.
The document summarizes how to write a character device driver in Linux. It covers the anatomy of a device driver including the user interface via device files, and kernel interfaces via file operations and major/minor numbers. It describes registering a character driver by defining file operations, reserving major/minor numbers, and associating them. Open and release functions handle initialization and cleanup. Read/write functions transfer data between userspace and hardware. Ioctl allows extending functionality.
This document discusses C language files input/output (I/O), the preprocessor, and conditional compilation. It covers:
- Types of files for I/O: text and binary files. Text files store plain text while binary files store data in 0s and 1s.
- File operations in C: creating, opening, closing files and reading/writing data. Functions like fopen(), fclose(), fprintf(), fscanf(), fread(), fwrite() are used.
- The preprocessor allows inclusion of header files and definition of macros to transform code before compilation. Directives like #include, #define are used.
- Conditional compilation allows certain code blocks to be included or excluded
The document discusses various concepts related to files in a UNIX system. It defines files as building blocks of an operating system and describes the different types of files like regular files, directory files, device files, FIFO files, etc. It explains key concepts like inodes, file attributes, directory structure, hard links and symbolic links. The document provides detailed information about each file type and how they are represented and used in a UNIX file system.
- Linux originated as a clone of the UNIX operating system. Key developers included Linus Torvalds and developers from the GNU project.
- Linux is open source, multi-user, and can run on a variety of hardware. It includes components like the Linux kernel, shell, terminal emulator, and desktop environments.
- The document provides information on common Linux commands, files, users/groups, permissions, and startup scripts. It describes the Linux file system and compression/archiving utilities.
CompTIA Linux+ Powered by LPI certifies foundational skills and knowledge of Linux. With Linux being the central operating system for much of the worldâs IT infrastructure, Linux+ is an essential credential for individuals working in IT, especially those on the path of a Web and software development career. With CompTIAâs Linux+ Powered by LPI certification, youâll acquire the fundamental skills and knowledge you need to successfully configure, manage and troubleshoot Linux systems. Recommended experience for this certification includes CompTIA A+, CompTIA Network+ and 12 months of Linux admin experience. No prerequisites required.
Poking The Filesystem For Fun And Profitssusera432ea1
Â
1) The document discusses writing a rogue filesystem driver that could be used as an attacker tool. It covers motivation, filesystem internals, types of filesystem drivers, and how to write a rogue filesystem driver by implementing functions like superblock operations, inode operations, and file operations.
2) A rogue filesystem driver could be difficult to detect and could selectively spoof, block, or hide file contents to gain a strong foothold in the system. It does not require hooking system calls or compromising the kernel in the same way.
3) Key aspects of developing a rogue driver involve registering the filesystem type, setting up superblock operations, and implementing inode, directory, and file operations to handle
This document provides an overview of file handling in Python. It discusses different file types like text files, binary files, and CSV files. It explains how to open, read, write, close, and delete files using functions like open(), read(), write(), close(), and os.remove(). It also covers reading and writing specific parts of a file using readline(), readlines(), seek(), and tell(). The document demonstrates how to handle binary files using pickle for serialization and deserialization. Finally, it shows how the os module can be used for file operations and how the csv module facilitates reading and writing CSV files.
Linux çłťçľąç¨ĺź--珏ä¸çŤ i/o ĺ˝ĺźčžéç§ć
Â
The document discusses Linux low-level I/O routines including system calls for file manipulation such as open(), read(), write(), close(), and ioctl(). It describes how files are represented in UNIX as sequences of bytes and different file types. It also covers the standard C I/O library functions, file descriptors, blocking vs non-blocking I/O, and other system calls related to file I/O like ftruncate(), lseek(), dup2(), and fstat(). Examples of code using these system calls are provided.
The document provides an introduction to Linux, including its history and origins. It discusses how Linux was originally developed by Linus Torvalds as an open source alternative to UNIX. It also summarizes some key Linux distributions like Red Hat Linux and describes basic Linux commands, file structures, and permissions.
Linux celebrated its 25th birthday on August 25, 2015. The document discusses the history and basics of Linux, including:
- Linux was created in 1991 by Linus Torvalds as an open-source kernel based on UNIX.
- It discusses Linux security models and permissions. Files have owners, groups, and permissions to control access.
- It provides an overview of basic Linux commands for starting the X server, changing passwords, editing text files, running commands and getting help.
Ăhnlich wie Linux System Programming - File I/O (20)
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumMJDuyan
Â
(đđđ đđđ) (đđđŹđŹđ¨đ§ đ)-đđŤđđĽđ˘đŚđŹ
đđ˘đŹđđŽđŹđŹ đđĄđ đđđ đđŽđŤđŤđ˘đđŽđĽđŽđŚ đ˘đ§ đđĄđ đđĄđ˘đĽđ˘đŠđŠđ˘đ§đđŹ:
- Understand the goals and objectives of the Edukasyong Pantahanan at Pangkabuhayan (EPP) curriculum, recognizing its importance in fostering practical life skills and values among students. Students will also be able to identify the key components and subjects covered, such as agriculture, home economics, industrial arts, and information and communication technology.
đđąđŠđĽđđ˘đ§ đđĄđ đđđđŽđŤđ đđ§đ đđđ¨đŠđ đ¨đ đđ§ đđ§đđŤđđŠđŤđđ§đđŽđŤ:
-Define entrepreneurship, distinguishing it from general business activities by emphasizing its focus on innovation, risk-taking, and value creation. Students will describe the characteristics and traits of successful entrepreneurs, including their roles and responsibilities, and discuss the broader economic and social impacts of entrepreneurial activities on both local and global scales.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
Â
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
Main Java[All of the Base Concepts}.docxadhitya5119
Â
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Â
IvĂĄn Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
Â
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analyticsâ feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
Communicating effectively and consistently with students can help them feel at ease during their learning experience and provide the instructor with a communication trail to track the course's progress. This workshop will take you through constructing an engaging course container to facilitate effective communication.
2. Systems Programming
⢠Systems programming involves the development of the
individual pieces of software that allow the entire
system to function as a single unit.
⢠Systems programming involves many layers such as the
operating system (OS), firmware, and the development
environment.
⢠System programming concepts are varies based on
operating systems.
⢠Example:
â Windows OSď Windows System programming
â Linux OSď Linux System programming
â MAC OSď Mac System Programming
3. Cornerstones of System Programming
in LINUX
⢠system calls:
â System programming starts and ends with system
calls
â System calls are function invocations made from
user spaceâyour text editor, favorite game, and
so on to requests a service from the kernel( core
part of OS)
4. Cornerstones of System Programming
in LINUX
⢠the C library:
â On modern Linux systems, the C library is provided
by GNU libc, abbreviated glibc.
â The GNU C Library project provides the core
libraries for the GNU system
â GNU is an operating system that is free software
5. Cornerstones of System Programming
in LINUX
⢠The C Compiler
â In Linux, the standard C compiler is provided by
the GNU Compiler Collection (gcc).
â A compiler is a special program that processes
statements written in a particular programming
language and turns them into machine language
or "code" that a computer's processor uses.
6. APIs & ABIs
⢠API
â It stands for Application Programming Interface
â It is a software intermediary that allows two applications to talk
to each other.
â It is based on source code
⢠ABI
â It stands for Application binary interface
â an ABI defines the binary interface between two or more pieces
of software on a particular architecture
â It defines how an application interacts with itself, how an
application interacts with the kernel, and how an application
interacts with libraries.
â It is based on machine code/object code
7. Opening Files
⢠A file is opened and a file descriptor is obtained
with the open() system call.
⢠Syntax:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open (const char *name, int flags);/opens existing file
int open (const char *name, int flags, mode_t mode);/it
will create a new file if it does not exist/
Header Files
8. Opening Files
⢠int open (const char *name, int flags);
File name with path Specifies mode
int open (const char *name, int flags, mode_t mode);
File name with path O_CREAT Specifies mode
9. Opening Files
⢠The following are some of values for flag and
mode parameters:
1.O_RDONLY-----Open for reading only.
2.O_WRONLY-----Open for writing only.
3.O_RDWR---------Open for reading and writing.
4. O_CREAT---------Create the file if it doesn't exist.
5.O_EXCL----When used with O_CREAT, if the file already
exists it is an error and the open() will fail
6. O_APPEND------Open the file in append mode
10. Opening Files
⢠Example program:
#include<stdio.h>
#include<fcntl.h>
#include<errno.h>
int main()
{
// if file does not have in directory
// then file foo.txt is created.
int errno;
int fd = open("foo.txt", O_RDONLY);
printf("fd = %d/n", fd);
if (fd ==-1)
{
// print which type of error have in a code
printf("Error Number % dn", errno);
// print program detail "Success or failure"
perror("Program");
}
return 0;
}
Header files
Main function
11. Opening Files
⢠Fd:
â It stands for file descriptor
â File descriptor is integer that uniquely identifies an opened
file.
â A file descriptor is a non-negative integer, generally
represented in the C programming language as the type int
⢠Most of the functionsdeclared are in
the <fcntl.h> header ,<stdio.h> and <errno.h>
⢠Return 0 is the statement which returns 0 on the
success after finishing the program execution
and returning a non-zero number means failure
12. Opening Files
⢠Linux is the multi-user operating system which
can be accessed by many users simultaneously.
⢠But this raises security concerns as an unsolicited
user can corrupt, change or remove crucial data.
⢠For effective security, Linux divides authorization
into 2 levels:
â Ownership
â Permission
13. Opening Files
⢠Ownership:
â Every file and directory on your Unix/Linux system is
assigned 3 types of owner, given below:
⢠User
â A user is the owner of the file. By default, the person who created
a file becomes its owner. Hence, a user is also sometimes called
an owner.
⢠Group
â A user- group can contain multiple users. All users belonging to a
group will have the same access permissions to the file.
â Suppose you have a project where a number of people require
access to a file.
â Instead of manually assigning permissions to each user, you could
add all users to a group, and assign group permission to file such
that only this group members and no one else can read or modify
the files.
⢠Other
â Any other user who has access to a file
â Practically, it means everybody else.
14. Opening Files
⢠Permissions
â Every file and directory in your UNIX/Linux system
has following 3 permissions defined for all the 3
owners discussed above.
â The three permissions are
⢠Read:This permission give you the authority to open
and read a file
⢠Write:The write permission gives you the authority to
modify the contents of a file.
⢠Execute:This permission give you the authority to
execute a file
16. Opening Files
⢠The creat() Function/System call:
â Create and open a file
⢠Syntax:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int creat (const char *name, mode_t mode);
Header files
Name of file
Mode
17. Opening Files
⢠Return Values and Error Codes
â Both open() and creat() return a file descriptor on
success.
â On error, both return â1, and set errno to an
appropriate error value
18. Reading via read()
⢠The mechanism used for reading is the read()
system call.
⢠Syntax:
#include <unistd.h>
ssize_t read (int fd, void *buf, size_t len);
File descriptor Address of
first Byte
Length or count
19. Reading via read()
⢠When read() returns successfully, its return
value is the number of bytes actually read and
placed in the buffer.
⢠If len(third parameter) is zero, read returns
zero and has no other results.
⢠On success a non-negative integer is returned
indicating the number of bytes actually read.
⢠Otherwise, a -1 is returned.
20. Reading via read()
⢠A call to read() can result in many possibilities:
â The call returns a value equal to len
â The call returns a value less than len, but greater
than zero(if any interrupt occurs during read)
â The call returns 0. This indicates EOF. There is
nothing to read.
â The call blocks because no data is currently
available
â The call returns â1, and errno is set to EINTR or
EAGAIN.
21. Reading via read()
Nonblocking Reads
⢠By default, read() waits until at least one byte is
available to return to the application; this default
is called "blocking" mode.
⢠Alternatively, individual file descriptors can be
switched to "non-blocking" mode, which means
that a read() on a slow file will return
immediately, even if no bytes are available.
⢠This is called nonblocking I/O; it allows
applications to perform I/O, potentially on
multiple files, without ever blocking
22. Reading via read()
Other Error Values
⢠Possible errno values after a failure on read() include:
â EBADF
⢠The given file descriptor is invalid or is not open for reading.
â EFAULT
⢠The pointer provided by buf is not inside the calling processâs
address space.
â EINVAL
⢠The file descriptor is mapped to an object that does not allow
reading.
â EIO
⢠A low-level I/O error occurred.
23. Reading via read()
Size Limits on read()
⢠The size_t and ssize_t types are used for read()
⢠The size_t type is used for storing values used to
measure size in bytes.
⢠The ssize_t type is a signed version of size_t (the
negative values are used to connote errors).
⢠the maximum value of an ssize_t is SSIZE_MAX
which is 2,147,483,647 bytes on a 32- bit
machine
24. Writing with write()
⢠The most basic and common system call used
for writing is write().
⢠It writes data from a buffer declared by the
user to a given device, such as a file
⢠This is the primary way to output data from a
program by directly using a system call
⢠Syntax:
#include <unistd.h>
ssize_t write (int fd, const void *buf, size_t count);
File descriptor
Destination
Source Length of the data to
be written
25. Writing with write()
⢠On success, the number of bytes written is
returned.
⢠On error, â1 is returned and errno is set
appropriately
⢠Partial writes:
â a successful write() may transfer fewer than count
bytes.
â Such partial writes can occur for various reasons
⢠If there was insufficient space on the disk device to write all
of the requested bytes
⢠Because of interrupt
26. Writing with write()
⢠Append Mode:
â When fd is opened in append mode (via O_APPEND),
writes do not occur at the file descriptorâs current file
position. Instead, they occur at the current end of the
file.
⢠Nonblocking Writes
â When fd is opened in nonblocking mode (via
O_NONBLOCK), and the write as issued would
normally block, the write() system call returns â1 and
sets errno to EAGAIN
â The request should be reissued later
27. Writing with write()
⢠Other Error Codes
â EBADF:The given file descriptor is not valid or is
not open for writing
â EFAULT:The pointer provided by buf points outside
of the processâs address space
â EINVAL:The given file descriptor is mapped to an
object that is not suitable for writing
â ENOSPC:The filesystem backing the given file
descriptor does not have sufficient space.
28. Writing with write()
⢠Size Limits on write()
â If count is larger than SSIZE_MAX, the results of the call to
write() are undefined
â A call to write() with a count of zero results in the call
returning immediately with a return value of 0.
⢠Behavior of write()
â when a user-space application issues a write() system call,
the Linux kernel performs a few checks and then simply
copies the data into a buffer.
â Later, in the background,the kernel gathers up all of the
dirty buffers, which are buffers that contain data newer
than what is on disk, sorts them optimally, and writes
them out to disk
29. Synchronized I/O
User issues write() to write some
data which contains three lines to file
called Sample.txt located in your z
drive
Kernel or OS accept the request and collect data from
write
Time frame1:data is collected to buffer
Time Frame2:data is collected to buffer
Time Frame 3:data is Collected to buffer
And then
It will sort the data in buffers and in optimal time the
consolidated data will be moved to sample.txt located
in your z drive
request
Process
30. Synchronized I/O
⢠By default, the Linux kernel writes data to disk
asynchronously.
⢠Writes are buffered (cached) in memory, and
written to the storage device at the optimal
time.
⢠The Synchronous I/O provides some functions
to ensure that all operations are finish before
they return.
31. Synchronized I/O
⢠Sync System call:
â The sync system call forces an immediate write of all
cached data to disk but it doesnât wait to complete.
â This call initiates the process of committing all buffers
to disk.
⢠Syntax:
sync [OPTION] [FILE]...
⢠Examples:
1. sync -d: This option sync only file data not
metadata
2. sync -f: This option will sync the file systems
which contains the files.
32. Synchronized I/O
fsync() and fdatasync()
⢠Syntax of fsync()
#include <unistd.h>
int fsync (int fd);
⢠The call to above function ensures that all dirty data
associated with the file mapped by the file descriptor
fd are written back to disk.
⢠The file descriptor fd must be open for writing.
⢠The call writes back both data and metadata, such as
creation timestamps and other attributes
⢠It will not return until the hard drive says that the data
and metadata are on the disk
⢠Metadata summarizes basic information about data.
33. Synchronized I/O
fsync() and fdatasync()
⢠Syntax for fdatasync()
#include <unistd.h>
int fdatasync (int fd);
⢠A call to fdata sync() will flush a fileâs size,
since you need that to read the file correctly.
⢠The call does not guarantee that nonessential
metadata is synchronized to disk, and is
therefore potentially faster
34. Synchronized I/O
O_SYNC Flag and O_RSYNC
⢠O_SYNC requires that any write operations
block until all data and all metadata have been
written to persistent storage.
⢠The O_RSYNC flag specifies that only normal
data be synchronized after each write
operation, not metadata.
35. Direct I/O
⢠The Linux kernel, like any modern operating system
kernel, implements a complex layer of caching,
buffering, and I/O management between devices and
applications.
⢠A high-performance application may wish to bypass
this layer of complexity and perform its own I/O
management.
⢠Providing the O_DIRECT flag to open() instructs the
kernel to minimize the presence of I/O management.
⢠When this flag is provided, I/O will initiate directly from
user-space buffers to the device, bypassing the page
cache
36. Direct I/O
⢠All I/O will be synchronous; operations will not
return until completed.
⢠For an I/O operation to be performed as direct
I/O, it must meet certain alignment criteria.
⢠The alignment constraints are usually determined
by the disk driver, the disk controller, and the
system memory management hardware and
software.
⢠If a request fails to meet the alignment
constraints for direct I/O, the request is
performed as data synchronous I/O.
37. Closing Files
⢠After a program has finished working with a file
descriptor, it can unmap the file descriptor from the
associated file via the close() system call:
#include <unistd.h>
int close (int fd);
⢠A call to close() unmaps the open file descriptor fd and
disassociates the file from the process.
⢠It is a common mistake to not check the return value of
close().
⢠There are a handful of possible errno values on failure.
Other than EBADF the most important error value is
EIO, indicating a low-level I /O error probably unrelated
to the actual close
38. Seeking with lseek()
⢠lseek is a system call that is used to change
the location of the read/write pointer of a file
descriptor.
⢠Syntax:
#include <sys/types.h>
#include <unistd.h>
off_t lseek (int fd, off_t pos, int origin);
39. Seeking with lseek()
⢠SEEK_CUR
â The current file position of fd is set to its current value
plus pos, which can be negative, zero, or positive. A
pos of zero returns the current file position value.
⢠SEEK_END
â The current file position of fd is set to the current
length of the file plus pos, which can be negative,
zero, or positive. A pos of zero sets the offset to the
end of the file.
⢠SEEK_SET
â The current file position of fd is set to pos. A pos of
zero sets the offset to the beginning of the file.
40. Seeking with lseek()
Error Values
⢠EBADF:The given file descriptor does not refer to
an open file descriptor
⢠EINVAL:The value given for origin is not one of
SEEK_SET, SEEK_CUR, or SEEK_END, or the
resulting file position would be negative.
⢠EOVERFLOW:The resulting file offset cannot be
represented in an off_t.
⢠ESPIPE:The given file descriptor is associated with
an unseekable object, such as a pipe,FIFO, or
socket.
41. Positional Reads and Writes
⢠In lieu of using lseek(), Linux provides two variants of
the read() and write() system calls
⢠Both receive the file position from which to read or write
⢠Upon completion, they do not update the file position
⢠The read form is called pread():
#define _XOPEN_SOURCE 500
#include <unistd.h>
ssize_t pread (int fd, void *buf, size_t count, off_t pos);
⢠This call reads up to count bytes into buf from the file
descriptor fd at file position pos.
42. Positional Reads and Writes
⢠The write form is called pwrite():
#define _XOPEN_SOURCE 500
#include <unistd.h>
ssize_t pwrite (int fd, const void *buf, size_t count, off_t pos);
⢠This call writes up to count bytes from buf to the file
descriptor fd at file position pos.
43. Truncating Files
⢠Linux provides two system calls for truncating the
length of a file, both of which are defined and required
(to varying degrees) by various POSIX standards.
⢠They are:
#include <unistd.h>
#include <sys/types.h>
int ftruncate (int fd, off_t len);
⢠and:
#include <unistd.h>
#include <sys/types.h>
int truncate (const char *path, off_t len);
44. Truncating Files
⢠The most common use of these system calls is to
truncate a file to a size smaller than its current
length
⢠The ftruncate() system call operates on the file
descriptor given by fd, which must be open for
writing
⢠The truncate() system call operates on the
filename given by path, which must be writable.
⢠Both return 0 on success. On error, they return â1
and set errno as appropriate
45. Multiplexed I/O
⢠Multiplexed I/O allows an application to
concurrently block on multiple file descriptors and
receive notification when any one of them
becomes ready to read or write without blocking.
⢠With I/O multiplexing, we call select or poll and
block in one of these two system calls, instead of
blocking in the actual I/O system call.
46. Multiplexed I/O
⢠Select is a system call and application programming
interface (API) in Unix-like and POSIX-compliant
operating systems for examining the status of file
descriptors of open input/output channels
⢠Syntax:
int select (int n,
fd_set *readfds,
fd_set *writefds,
fd_set *exceptfds,
struct timeval *timeout);
47. Multiplexed I/O
Argument Description
n This is an integer one more than the maximum of any file
descriptor in any of the sets
*readfds file descriptors to be checked for being ready to read
*writefds file descriptors to be checked for being ready to Write
*exceptfds file descriptors to be checked for error conditions
*timeout specifies a maximum interval to wait for the selection to
complete
48. Multiplexed I/O
⢠Poll system call:
â Unlike select(), with its inefficient three bitmask-based
sets of file descriptors, poll() employs a single array of
nfds pollfd structures, pointed to by fds
⢠Syntax:
#include <poll.h>
int poll (struct pollfd *fds, nfds_t nfds, int timeout);
It contains the set events
which have to checked for
the availbility
Number of fds
Time limit
49. Multiplexed I/O
⢠Structure of pollfd *fds
#include <poll.h>
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events to watch */
short revents; /* returned events witnessed */
};
50. Kernel Internals
⢠The kernel subsystem consists of :
â the virtual filesystem (VFS),
â the page cache, and
â page writeback
⢠The virtual filesystem, occasionally also called a virtual
file switch, is a mechanism of abstraction that allows
the Linux kernel to call filesystem functions and
manipulate filesystem data without knowingâor even
caring aboutâthe specific type of filesystem being
used.
⢠Linux file system is generally a built-in layer of a Linux
operating system used to handle the data management
of the storage. It helps to arrange the file on the disk
storage. It manages the file name, file size, creation
date, and much more information about a file.
51. Kernel Internals
⢠The Page Cache:
â The page cache is an in-memory store of recently
accessed data from an on-disk filesystem.
â Disk access is painfully slow, particularly relative to
todayâs processor speeds.
â Storing requested data in memory allows the
kernel to fulfill subsequent requests for the same
data from memory, avoiding repeated disk access.
52. Kernel Internals
⢠Page Writeback
â Eventually the dirty buffers need to be committed to
disk, synchronizing the on-disk files with the data in
memory. This is known as writeback. It occurs in two
situations:
⢠When free memory shrinks below a configurable threshold,
dirty buffers are written back to disk so that the now-clean
buffers may be removed, freeing memory.
⢠When a dirty buffer ages beyond a configurable threshold,
the buffer is written back to disk. This prevents data from
remaining dirty indefinitely.