Skip to content
Advertisement

Tag: posix

Wait for signal from parent and does job and blocks again

Write a program that can display a text string (consisting only of the 26 alphabets and spaces). The program should fork 27 worker processes. Each worker process runs an infinite loop in which it waits for a signal from the controller (i.e., parent), sleeps for 1 sec, prints its pre-defined character, signals the controller, then blocks again. The controller reads

Strange POSIX semaphore behavior (stuck on sem_wait on Linux)

I’m trying to solve a school problem envolving POSIX semaphores. I’ve run into an issue that I’ve narrowed down to this simplified code: When compiling (using gcc -Wall -pthread sems.c -o sems) and running this program in Linux, I get the following output (the program doesn’t finish execution): Because I call sem_post(&sem) in the child process, I would expect the

Stop grep message from posting

I am working on a script that take 1 string argument and a file. I want it so that if a file is put in that doesn’t exist, then it will display the “filename cannot be read” message. That part does work however it also displays a “grep: grep.txt: No such file or directory” message. Is there any way to

POSIX threads vs parallelism

Do POSIX threads (managing by pthread library) works parallelly? My lecturer has told us that this library creates only user threads, that are not managed by Linux kernel. I wrote some code that fill large matrix and compared times of execution for threads and whole program and it seems to works parallelly. Can I use this library to creating parallel

Where is ssize_t defined in Linux?

OS: Debian 9 (Linux 4.9) Compiler: GCC 8.2 Currently I am including <stddef.h> (where size_t is defined) and <stdint.h> (where most integral types are defined), but I still don’t have ssize_t. Where is it defined? Answer ssize_t is defined in sys/types.h. Per the POSIX documentation: NAME sys/types.h – data types SYNOPSIS DESCRIPTION The header shall define at least the following

Advertisement