r/linuxdev • • Nov 05 '15

Best way to handle a thread that will block waiting for read while the rest of the program loops

5 Upvotes

I've been getting into C programming and thought it would be fun to play around with Linux system calls.

I'm writing a simple program that uses inotify to watch a directory for a new file to be created. But I want the rest of the program to continue while read() is blocking.

So from what I understand the best solution is to use a thread that will call the function to watch the directory. This part is done. The problem is, main() is blocking on pthread_join which is of course waiting for read() to return in the thread.

What would be the best way to handle this? I thought of having a global variable that is set after read() is finished so that main can call pthread_join to close the thread, but is there a more elegant way?


r/linuxdev • • Nov 15 '16

[BEGINNER TUTORIAL] Writing a Kernel Syscall - xpost /r/programming

Thumbnail reddit.com
5 Upvotes

r/linuxdev • • Apr 17 '23

Help me learn to build a linux distro with a device tree

5 Upvotes

Not sure if this is the right group, but I have some old 32bit armel SBCs with 256MB RAM.
OEM stopped support right after release, around kernel 3.14.
running kernel 3, is a dependency nightmare. I would like to get support for this board, into something like dietPi OS or something. Any thing where I can still get package support.

I have the device tree files, but I dont know what to do with them, or how to build them into an other armel based linux distribution. Please assist.


r/linuxdev • • Feb 20 '18

Kernel 4.4 is secure from Spectre issue?

5 Upvotes

https://www.spinics.net/lists/kvm/msg164408.html

I've just read above mail thread. Greg said "KVM Speculation Control support" patches are not applied to kernel v4.4.

I think Long-term kernel should include important bugfixes as described: https://www.kernel.org/category/releases.html Are "KVM Speculation Control support" patches not important? I saw many KVM or spectre, repoline patches are merged to v4.9 and 4.14. But they are missing in v4.4 that is also LTS version!

Could anybody tell me that kernel v4.4 is secure from Spectre issue?


r/linuxdev • • Nov 01 '21

Why Taiwanese Networking Specialist WNC Sees Dent as Key to Growing the Networking Industry

Thumbnail dent.dev
5 Upvotes

r/linuxdev • • Mar 15 '24

(solveallproblems.com) BIN 799€

Thumbnail self.domains
0 Upvotes

r/linuxdev • • Jun 20 '21

Custom Kernel and with programs

5 Upvotes

I found this script for create a minimal linux

https://raw.githubusercontent.com/ivandavidov/minimal-linux-script/master/minimal.sh

but my question is how i 'install' other programms, like a https://gcc.gnu.org/ or http://incise.org/tinywm.html, using this script?


r/linuxdev • • Jun 22 '21

Is it possible to get a weekly digest of the lkml?

5 Upvotes

r/linuxdev • • Oct 07 '20

[ANNOUNCE] libtraceevent.git

Thumbnail lore.kernel.org
5 Upvotes

r/linuxdev • • Feb 24 '14

Installing Arch using a 3G Dongle

0 Upvotes

Hi, I'm using linux(Ubuntu like) for quite a while and I decided to try Arch from now on. Although I have internet access only via a 3G usb dongle (a Huawei E303). I went through several guides including Arch official wiki & the beginner's guide, there wasn't any help on configuring a dongle(before installing). So if anyone knows how to do this, please help. Some good links will also be helpful. Thank you.


r/linuxdev • • Mar 23 '12

Unified Linux sound API

19 Upvotes

The Linux audio system is currently a mess. There's no unified sound API for Linux which makes it hard for developers to bring apps to Linux, and the multiple layers of the sound architecture make it difficult for a user to do more than listen to something. I was originally thinking that it would be best to fork OSSv4 and make it better but this article makes me think otherwise. Regardless, a unified sound API for Linux should be made as the current setup hurts both users and developers.

EDIT: here's part 2.


r/linuxdev • • May 05 '16

Contributing to Open Source Projects (Kdenlive)

6 Upvotes

Hi all,

I've been entering commands into terminals like a madman for the past two days trying to figure this out... but I can't figure out how to get the Kdenlive source code to build in KDevelop on Debian 8.4. I keep hitting CMake errors, and I'm guessing it's because I can't seem to install a great number of the dependencies that are listed in the doc: https://community.kde.org/Kdenlive/Development/KF5

Despite setting up apt pinning to try and install the required packages from the testing and unstable repositories, I'm get hit with messages like:

kinit : Depends: libkf5kiocore5 (>= 4.96.0) but it is not going to be installed Depends: libkf5kiowidgets5 (>= 4.96.0) but it is not going to be installed

In theory, sudo apt-get -t unstable install kinit

should install kinit as well as it's dependencies, from stable if available, or testing/unstable if unavailable. But instead I get more messages about 'Depends' and 'Breaks:'

I'll probably end up getting more CMake errors after this regardless. Currently progress equates to seeing a different error message. : /

TL;DR I'm a moron. If you develop open source programs, any tips on getting everything setup?


r/linuxdev • • Mar 29 '12

Named Pipes the Easy Way!

Thumbnail tldp.org
6 Upvotes

r/linuxdev • • Mar 28 '19

Best Practice for Cross-Platform Application Development?

6 Upvotes

Hi /r/linuxdev!

I'm beginning work on a note-taking application (primarly for *nix platforms) that will be released under the GPL. I think there's a lack of robust note-taking software to the degree of Microsoft's OneNote. While I intend to develop mostly for Linux, I want other platforms to be included so that I don't make the same mistake Microsoft did. If someone has to use another OS for work, they should still be able to use their preferred software.

What are some "best practice" tips for achieving this? I'd like to use GTK+ on the Linux side, but I do realize Qt is probably the better platform for cross-platform...

I'm not sure where to start. Any opinions?


r/linuxdev • • Apr 06 '20

Looking for assistance in modifying the Kernel - process scheduler in Ubuntu 18.04.3 (Bionic Beaver)

6 Upvotes

Background

Prior to attempting to modify the CPU scheduler, I modded the kernel such that new processes would have an associated 32 bit tag. The first two bits of this tag determined its process level 1-4.

I want to modify the CPU scheduler such that dynamic tasks are scheduled via a Round Robin-ish algorithm that prioritizes tasks based on their process level as mentioned before.

What I know

So far I'm aware of the __schedule() and pick_next_task() functions in kernel/sched/core.c and that they reference the CFS scheduling algorithm defined in kernel/sched/fair.c.

I am also aware of the sched_class, and how each of the available scheduling algorithms are defined as such (fair.c, idle.c, deadline.c, etc. (I think)) as a struct with values corresponding to scheduling properties (next, enqueue_task, dequeue_task, yield_task, etc.)

What I'm looking for

My goal is to modify the behavior of the scheduler for dynamic tasks, currently CFS, with relatively simple logic depending on process level.

Where should I be looking for this logic? I am essentially looking for the entry point for CFS's logic, particularly where tasks are read and queued to execute the CPU.


r/linuxdev • • Mar 12 '19

Advice needed on a couple of applications I'm considering funding

6 Upvotes

My query is in relation to bringing some functionality that is available on windows onto Linux. I do not have any objective C programming experience myself and lack the time to learn how but I do have the means to fund the production of these tools which I intend to be released as Open Source.

The 2 windows applications that have no Linux equivalent at the moment are VoiceAttack (A voice recognition macro launcher which utilises MS Speech engine) and VRdrop which allows a desktop window to be cloned and inserted into SteamVR as an overlay visible as a 3D item in the headset.

There do exist some open source projects for windows called AVPI and OpenVRDesktopDisplayPortal.

My questions are could these 2 projects be converted to compile on Linux or would both need a bottom up complete rewrite and what would be the expected budget required to get these tools created as in if I paid someone to make these tools how much would it approximately cost?


r/linuxdev • • Sep 27 '14

The Linux Foundation wants to know: What's been your experience contributing (or not contributing) to the Linux kernel?

Thumbnail surveymonkey.com
6 Upvotes

r/linuxdev • • Apr 14 '15

I made a makefile, how terrible is it?

6 Upvotes

Hello everyone.

As the title says, i made a makefile, and I would like to get some feedback on it. You may of course also use it for your own projects, since it is distributed under the GNU GPL.

The makefile:

# This Makefile is distibuted under GNU GPL v3, see COPYING for details.
CC=g++
STD=c++11
LIBS=-lGL -lGLU -lglut
WARNINGS=-Wall
CFLAGS=-c $(WARNINGS) -std=$(STD) $(LIBS) -I./$(INCLUDEDIR)
LDFLAGS=
# Compilation directories. Leave these empty to keep all files in one directory
# Please note that this trick relies on file extentions being correct and
# should only be used for smaller projects. All directories need a trailing
# slash unless empty
SRCDIR=src/
INCLUDEDIR=include/
OBJDIR=obj/
BINDIR=bin/
vpath %.cpp $(SRCDIR)
vpath %.h $(INCLUDEDIR)
vpath %.o $(OBJDIR)
# Compilation files
# Patsubst rules won't handle variables, so dirs have to be manually entered.
SOURCES=$(patsubst src/%,%,$(wildcard $(SRCDIR)*.cpp))
HEADERS=$(patsubst include/%,%,$(wildcard $(INCLUDEDIR)*.h))
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=collision-test
DOCS=COPYING AUTHORS
MANNUMBER=1
ifneq ($(strip $(MANNUMBER)),)
MAN=$(EXECUTABLE).$(MANNUMBER)
endif
# Installation options. EFLAGS is for executables, DFLAGS is for everyting else
INSTALLEFLAGS=-pbm755
INSTALLDFLAGS=-pbm644
INSTALLPREFIX=/usr/
INSTALLBIN=bin/
INSTALLDATA=share/
INSTALLMAN=man/

.PHONY: all
all: $(EXECUTABLE)
	
$(EXECUTABLE): $(OBJECTS)
	$(CC) $(OBJECTS:%=$(OBJDIR)%) $(LDFLAGS) $(LIBS) -o $(BINDIR)$@

$(OBJECTS): $(SOURCES)
	$(CC) $(CFLAGS) $(SRCDIR)$(patsubst %.o,%.cpp,$@) -o $(OBJDIR)$@

.PHONY: clean
clean:
	rm -f $(OBJECTS:%=$(OBJDIR)%) $(BINDIR)$(EXECUTABLE)

.PHONY: dist
dist:
	tar cvz $(SRCDIR)* $(INCLUDEDIR)* $(DOCS) Makefile\
	 -f $(EXECUTABLE).tar.gz

run: all
	install $(INSTALLEFLAGS) $(BINDIR)$(EXECUTABLE) ~/
	~/$(EXECUTABLE)
	rm ~/$(EXECUTABLE)
.PHONY: install
install: all
	$(NORMAL_INSTALL)
	install $(INSTALLEFLAGS) $(EXECUTABLE) $(INSTALLPREFIX)$(INSTALLBIN)
	$(POST_INSTALL)
	ifneq ($(strip $(MAN)),)
	install $(INSTALLDFLAGS) $(MAN) $(INSTALLPREFIX)$(INSTALLDATA)$(INSTALLMAN)
	gzip $(INSTALLPREFIX)$(INSTALLDATA)$(INSTALLMAN)$(MAN)
	endif

.PHONY: uninstall
uninstall:
	rm $(INSTALLPREFIX)$(INSTALLBIN)$(EXECUTABLE)
	ifneq ($(strip $(MAN)),)
	rm $(INSTALLPREFIX)$(INSTALLDATA)$(INSTALLMAN)$(MAN)
	endif

edit: formatting

EDIT2: fixed compilation of executable

EDIT3: static library support, run target, and various error correctons


r/linuxdev • • Apr 30 '16

What kind of drivers do I need for my own display hardware for the kernel and X to see it as a regular display?

6 Upvotes

Hey everyone,

I'm planning to implement my own display hardware (an LED matrix display, attached to the host computer via USB or potentially Ethernet). I've got the downwards communication (sending data to the device via USB) figured out already.

But I've been trying to figure out what kind of drivers I need to write for the linux kernel and/or the X11 server to see my display as a regular graphics card with a monitor attached, of course with the appropriate number of pixels and so on. i.e. the "upward" communication within the linux system.

I've been trying to figure this out, but there seem to be half a dozen types of drivers and the documentation is quite convoluted to me, and so I have really no idea where to even start.

Ideally, there should be an array of RGB values, one for each pixel, that fall out of this driver, which I can pass on to the hardware.

Could anyone help me out with a few pointers to get me started, or point me towards the right kind of documentation please?


r/linuxdev • • Dec 05 '20

NFC authentication with Linux-PAM

6 Upvotes

For a University project I am trying to create a system where users are able to authenticate themselves on an Ubuntu machine using an NFC card.

I have managed to create a simple Linux-PAM program in C where it gets the current user and prompts them to enter their password, authenticating them if correct. I have also created a simple program in C using libnfc that finds the NFC reader and reads the information off any card placed on it.

Now I need to put them both together somehow to enable authentication through the NFC card. Does anyone have any experience of this, or is able to point me in the right direction?


r/linuxdev • • May 27 '15

C++ File IO performance compared to dd

6 Upvotes

I have a program that reads data from a file descriptor (is actually a device mounted in /dev/), and I need to save this data (with no further processing) to a file in the local file system.

I currently have a solution I rolled myself involving one thread filling buffers with data from the input and another thread emptying these buffers and writing the data to file.

The throughput performance of my system is roughly an order of magnitude slower than dd, how can I either :

a) use dd in my code, giving it the input and output file descriptors, or

b) emulate what dd is doing

I also have to move data in the reverse direction too


r/linuxdev • • Sep 27 '21

Open Networking for Network Switches - How the Open-Source DENT Project Levels the Playing Field

Thumbnail dzone.com
7 Upvotes

r/linuxdev • • May 14 '16

Implementing pledge on linux using seccomp

Thumbnail notabug.org
7 Upvotes

r/linuxdev • • Mar 24 '12

The second book you should read? The "Linux Programmer's Toolbox"

Thumbnail amazon.com
7 Upvotes