Implementation of Dining Philosopher Problem in C programming using Semaphore itachay.com/2019/06/imple…
πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/abdullahriaz008
πŸ“…︎ Jun 30 2019
🚨︎ report
TIL in 1834, two French stock brokers were able to sneak messages into the government's semaphore telegraph system, letting them know about the movements of the Paris stock market five days ahead of local competitors in Bordeaux andreafortuna.org/2018/06…
πŸ‘︎ 333
πŸ’¬︎
πŸ‘€︎ u/shitthrower
πŸ“…︎ Jan 04 2022
🚨︎ report
C programming in windows with semaphores?

Working on a school project, we are supposed to use semaphores to stop multiple processes from interfering with the way that they interact with the same shared memory. I started up a c++ project in VS2015, created a .c file instead of a .cpp, and started including some of the files my professor told the class we would need. And I started running into some issues. He wants our programs to run on a unix server, but I am not familiar with unix and I don't have any unix machine to test on.

The issue I'm getting is that none of these files can be found by VS:

#include <unistd.h>   
#include <sys/sem.h>
#include <sys/ipc.h>
#include <sys/shm.h>   

My understanding is that these are files that really only exist in a unix system. Is there any way for me to write this program on my Windows computer? Like I said, I only have very limited experience with unix and I don't have access to a unix machine to test on. I'm open to suggestions for an IDE to use (please don't say emacs or vi), a compiler to use, and really just any kind of suggestion as to where I should start. I tried downloading MinGW and installing gcc, but MinGW does not include any of the files in they sys/ directory. I am very much lost, I'm just a lowly c++ programmer that has never tried C at all. All help is greatly appreciated.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/firepelt
πŸ“…︎ Feb 06 2016
🚨︎ report
Concurrent programming, how do i construct a semaphore?

i have a project where i have to write pseudocode for a semaphore, from the following text:

"Consider a scenario where a single taxi is taking Manchester United and Liverpool supporters from the city centre to the Saturday football game. The taxi can take four supporters at a time and it is always filled to capacity when carrying supporters. However the situation is never allowed to arise where the taxi contains one supporter of either team isolated on their own. The taxi carries out a number of trips and when it first arrives it randomly signals to one of the two waiting supporters’ queues. You can assume that there are always one or more supporters waiting in each queue when it is signaled. When a supporter enters the taxi and there is still some room for more supporters in the taxi the supporter (who has just joined the taxi) signal to another waiting supporter in one of the queues for them to also enter the taxi. Where possible the supporter will randomly select the queue to signal, however if necessary they will select a particular queue so as to ensure that no single supporter will be isolated in the taxi with opposing supporters.

The last supporter entering the taxi to complete a full cohort of four supporters in the taxi signals the taxi (driver) to take them to the football ground. The taxi takes them to their destination and then returns to repeat the cycle. Note that only the supporters (not the taxi driver) are able to differentiate between who is a Manchester United supporter and who is a Liverpool supporter."

In the scenario, it can either be 4 supports from man united in one taxi, 2 from each set of supporters, or 4 liverpool supporters. There shouldn't be a scenario where one set of supporters are outnumbered by the other

I'm having trouble applying what notes i have, and what help there is online to this problem.

Heres what ive done so far:

int numManInTaxi = 0; //current no. of ManU supporters in taxi
int numLivInTaxi = 0;

sem MaxUnitedFans = 4; // // max no. of supporters that can fit in taxi sem MaxLivFans = 4;

sem MMutexSem = 1; sem LMutexSem = 1;

CO for (count = 1 to ManUSupporter){ ManUProcess[count];

// for (count = 1 to LivSupporter){ LivProcess[count]; OC } /*end main process

process ManUProcess [i = 1 to N]{

P(MMutexSem); // mutually exclusice access for United supporter numManUInTaxi++;

if ((numManInTaxi+numLivInTaxi) < 4) {
if (numManuInTaxi == 3) { // signal the Man queue numManUInTaxi++; } else if (

... keep reading on reddit ➑

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/944jmc
πŸ“…︎ Mar 01 2017
🚨︎ report
TIL that the Beatles don't actually spell out "HELP" in semaphore on their album cover for "Help !", instead just random letters that looked better together. en.wikipedia.org/wiki/Hel…
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/gamasco
πŸ“…︎ Dec 14 2021
🚨︎ report
POSIX semaphores - why can't I use the same semaphores in two programs.

Hello, I'm working on a sleeping barber problem, using POSIX semaphores and shared memory.When I run code for barber, I don't get any problem with creating semaphores.

However, when I run code for client it instantly terminates. I checked using valgrind what might be the case and here is what I got, after using valgrind --leak-check=full ./client 10 5 (the 10 and 5 are just arguments for the program.

==646== Memcheck, a memory error detector
==646== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==646== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==646== Command: ./client 10 10
==646==
==646==
==646== HEAP SUMMARY:
==646==     in use at exit: 251 bytes in 8 blocks
==646==   total heap usage: 8 allocs, 0 frees, 251 bytes allocated
==646==
==646== 24 bytes in 1 blocks are possibly lost in loss record 4 of 8
==646==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==646==    by 0x499EED3: tsearch (tsearch.c:338)
==646==    by 0x4871A8C: check_add_mapping (sem_open.c:113)
==646==    by 0x4871E64: sem_open (sem_open.c:181)
==646==    by 0x1094C9: main (client.c:32)
==646==
==646== 39 bytes in 1 blocks are possibly lost in loss record 8 of 8
==646==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==646==    by 0x4871A1F: check_add_mapping (sem_open.c:96)
==646==    by 0x4871E64: sem_open (sem_open.c:181)
==646==    by 0x1094C9: main (client.c:32)
==646==
==646== LEAK SUMMARY:
==646==    definitely lost: 0 bytes in 0 blocks
==646==    indirectly lost: 0 bytes in 0 blocks
==646==      possibly lost: 63 bytes in 2 blocks
==646==    still reachable: 188 bytes in 6 blocks
==646==         suppressed: 0 bytes in 0 blocks
==646== Reachable blocks (those to which a pointer was found) are not shown.
==646== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==646==
==646== For lists of detected and suppressed errors, rerun with: -s
==646== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

This is the code for barber:

 #include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;semaphore.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include "functions.h"
#include &lt;sys/mman.h&gt;
#include &lt;unistd.h&gt;
#def
... keep reading on reddit ➑

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/marochan442
πŸ“…︎ Jan 07 2021
🚨︎ report
Sema-what? Semaphores! Learn about them in my latest tutorial youtube.com/watch?v=4XmtZ…
πŸ‘︎ 15
πŸ’¬︎
πŸ‘€︎ u/bitbirdy
πŸ“…︎ Jan 10 2022
🚨︎ report
Nice afternoon at semaphore beach, South Australia
πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/Amydancingagain
πŸ“…︎ Jan 01 2022
🚨︎ report
The first basement floor has a secret room with these weird images on the wall. I believe they're in flag semaphore but not quite. Does anyone want to take a crack at it or have any other cryptology knowledge? reddit.com/gallery/rkd9bf
πŸ‘︎ 52
πŸ’¬︎
πŸ‘€︎ u/The_Negotiator_B1
πŸ“…︎ Dec 20 2021
🚨︎ report
❗COVID-19 Alert 😷 Hyde Park, QF691, Victor Harbor, Wayville, Fullatorn Semaphore, Harbour Town

CLOSE CONTACT EXPOSURE LOCATIONS

Hyde Park – Hello Neighbour Cafe

Β· Tuesday 30 November – 12.15pm to 2.45pm

Qantas Flight QF691 – Melbourne to Adelaide (Rows 3 to 7)

Β· Monday 29 November – arrived 5.45pm

Victor Harbor – Nino's Cafe

Β· Sunday 28 November – 8.15pm to 9.15pm

Unvaccinated contacts – If you are unvaccinated and were at one of the above Close Contact exposure location at the specified date and time, you must:

Β· immediately quarantine for 14 days since you were at the location

Β· get tested immediately

Β· get tested again on day 6 and day 13

Vaccinated contacts - If you are vaccinated and were at one of the above Close Contact exposure location at the specified date and time, you must:

Β· immediately quarantine for 7 days since you were at the location

Β· get tested immediately

Β· get tested again on day 6 and day 13

Β· not attend high risk settings or COVID Management Plan events for 14 days after exposure

Β· wear a surgical mask when around others

Β· avoid contact with vulnerable people, avoid non-essential activities where possible and avoid shared spaces and maintain physical distancing on days 8 to 14 after exposure.

CASUAL CONTACT EXPOSURE LOCATIONS

Fullarton – Torrens Health Office

Β· Wednesday 1 December – 7.30am to 10.15am

Β· Tuesday 30 November – 7.30am to 5.00pm

Β· Monday 29 November – 7.30am to 5.00pm

Semaphore – Sweet Amber Beer & Pizza

Β· Sunday 28 November – 4.45pm to 5.45pm

Wayville – Bowerbird Market Adelaide Showgrounds

Β· Sunday 28 November – 11.00am to 1.00pm

If you were at one of the above Casual Contact exposure locations at the specified dates and times, you must:

Β· get tested immediately and quarantine until you receive a negative result

Β· get tested again on day 6 and day 13

Β· wear a surgical mask when around others at all times

Β· avoid contact with vulnerable people (elderly, pregnant, young children), avoid non-essential activities where possible, avoid shared spaces and maintain physical distancing.

LOW RISK CASUAL CONTACT LOCATIONS

Adelaide Airport – Harbour Town Adelaide

Β· Sunday 28 November – 1.30pm to 5.00pm

Hyde Park – Parisi's Restaurant (Patrons)

Β· Monday 29 November – 12.15pm to 2.45pm

Qantas Flight QF691 – Melbourne to Adelaide (All rows excluding Rows 3 to 7)

Β· Monday 29 November – arrived 5.45pm

Tea T

... keep reading on reddit ➑

πŸ‘︎ 61
πŸ’¬︎
πŸ‘€︎ u/stuntguy3000
πŸ“…︎ Dec 03 2021
🚨︎ report
Several vermillion semaphores 🚩🚩🚩 v.redd.it/t0ho4x5n6i781
πŸ‘︎ 169
πŸ’¬︎
πŸ‘€︎ u/Shitposter95
πŸ“…︎ Dec 24 2021
🚨︎ report
Vulkan-CUDA Interoperability on Windows: Vulkan External Semaphore Behavior

I've been on the fence about posting this question here or on the CUDA subreddit; since it is a Vulkan semaphore that is exported, here it comes:

This question comes from the CUDA-Vulkan Interoperability sample.

I'd concentrated on the binary semaphore version however, the situation is similar for timeline semaphore version (controlled by #define _VK_TIMELINE_SEMAPHORE in VulkanBaseApp.h).

When I comment out the cudaSignalExternalSemaphoresAsync() call , which signals the m_cudaSignalSemaphore, in VulkanCudaSineWave::drawFrame() I expect the program to hang since the Vulkan pipeline waits for the m_vkWaitSemaphore (m_cudaSignalSemaphore is the exported version of m_vkWaitSemaphore), but it does NOT; nary a peep from validation about this.

What could be going on?

πŸ‘︎ 16
πŸ’¬︎
πŸ‘€︎ u/Tensorizer
πŸ“…︎ Oct 30 2021
🚨︎ report
How to use a Binary Semaphore for taking ang giving activity indication?

Hi. Thanks for any help on the following

I need to write a program that creates two tasks: one for reading characters from the serial port and the other for indicating received characters on the serial port. Use a binary semaphore to notify serial port activity to the indicator task.

Task 1: task reads characters from debug serial port and echoes them back to the serial port. When a character is received the task sends an indication (= gives the binary semaphore) to blinker task.

Task 2: this task blinks the led once (100 ms on, 100 ms off) when it receives activity indication (= takes the binary semaphore).

These are the functions I should use:

- void Board_UARTPutChar(char ch);

* u/brief Classic implementation of itoa -- integer to ASCII

* u/param value : value to convert

* u/param result : result string

* u/param base : output radix

* u/return result string or NULL

- int Board_UARTGetChar(void);

* u/brief Prints a string to the UART

* u/param str : Terminated string to output

* u/return None

- void Board_UARTPutSTR(const char *str);

* u/brief Sets the state of a board LED to on or off

* u/param LEDNumber : LED number to set state for

* u/param State : true for on, false for off

* u/return None

they should be used (primarily on int main(void) ) in this code:

#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

#include &lt;cr_section_macros.h&gt;
#include "FreeRTOS.h"
#include "task.h"
#include "heap_lock_monitor.h"
//#include "DigitalIoPin.cpp"
//#include "DigitalIoPin.h"

/* Sets up system hardware */
static void prvSetupHardware(void)
{
	SystemCoreClockUpdate();
	Board_Init();

	/* Initial LED0 state is off */
	Board_LED_Set(0, false);
}

/* LED1 toggle thread */
static void vLEDTask1(void *pvParameters) {
	bool LedState = false;

	while (1) {
		Board_LED_Set(0, true);
		vTaskDelay(1000 * configTICK_RATE_HZ /1000);
		Board_LED_Set(0, false);
		vTaskDelay(1000 * configTICK_RATE_HZ /1000);
		Board_LED_Set(0, true);
		vTaskDelay(1000 * configTICK_RATE_HZ /1000);
		Board_LED_Set(0, false);
		vTaskDelay(1000 * configTICK_RATE_HZ /1000);
		Board_LED_Set(0, true);
		vTaskDelay(1000 * configTICK_RATE_HZ /1000);
		Board_LED_Set(0, false);
		vTaskDelay(1000 * configTICK_
... keep reading on reddit ➑

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Nov 04 2021
🚨︎ report
Fun little problem for people learning semaphores for threaded programming (C++/CLI but can be modified for any language easily)

Just had to do this for a programming class and I thought it was quite clever so I thought I would offer it up for anyone trying to learn semaphores.

This is a C++/CLI program that creates three threads, which print a letter repeatedly (A, B, and C). The task is to modify the program so that it now repeatedly prints AAABBCAAABBCAAABBC... (Three A's, two b's, and one c) over and over again. The challenge? You may not edit or delete any part of the program, and you may ONLY add semaphore statements. No other variables, no control structures, nothing. For C++/CLI, this would be statements of the form:

Semaphore S = gcnew Semaphore...

S->WaitOne()

S->Release()

I have one solution if you get stumped. And if anyone wants to translate this for another language and post it that would be great.

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/dsampson92
πŸ“…︎ Nov 05 2011
🚨︎ report
HELP! The semaphore timeout period has expired 0x80070079 /r/gopro/comments/rw6bch/…
πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Jan 04 2022
🚨︎ report
Semaphore error?? Advise please?
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/jcainkz
πŸ“…︎ Dec 29 2021
🚨︎ report
What’s with semis and semaphore violations?

I’ve lived here for over 10 years and some things stick out, like how common it is for people here to run red lights. It hasn’t seemed as common as in big cities that I’ve lived in.

And I’ve been seeing semis running reds, which seems even more dangerous and outrageous. I’d take speeding over running a red any day. And people seem to tolerate it. I’ve never seen anyone pulled over for it.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/MinnesotaGirl5
πŸ“…︎ Dec 19 2021
🚨︎ report
Drones signalling using semaphore in plain sight. What are they communicating ? v.redd.it/zzrcj4ouq6481
πŸ‘︎ 74
πŸ’¬︎
πŸ‘€︎ u/rainbowarriorhere
πŸ“…︎ Dec 07 2021
🚨︎ report
One of the C&IM, now IMRR property, searchlights guarding the South entrance of the Brick Yard in Springfield, IL. The brackets that made a semaphore/searchlight combo did actually move, but the South signal had its brackets bolted. I believe the North searchlight brackets still move. Credits N/A.
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Railfanning2005
πŸ“…︎ Jan 09 2022
🚨︎ report
ESP-IDF FreeRTOS: Semaphores vs stdatomic

I have a variable that is going to be accessed by two separate tasks, and possibly can be modified at the same time. On one task, the 16 bit unsigned integer can only be incremented (integer++), while on the other the same integer can only be decremented (integer--). I thought to use a semaphore but figured I can just use stdatomic and declare the variable as _Atomic instead of creating an entire semaphore for it. I looked around a bit and I couldn't really find anything saying if this was a bad idea or not, any thoughts on this? I know that task notifications are also a thing, but where does the use of stdatomic lie vs freeRTOS tools for these situations?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/blumpkinbeast_666
πŸ“…︎ Nov 11 2021
🚨︎ report
ID needed. Found in Semaphore south Australia. Thanks
πŸ‘︎ 22
πŸ’¬︎
πŸ‘€︎ u/isabel_77
πŸ“…︎ Dec 05 2021
🚨︎ report
semaphore (#1242) | Blind Stare - Shotgun Symphony+ [Impossibly Intense] 99.69% 1156/1337x 1xSB #9 | 261pp | 110.02ur | Unnoticed, second best acc osu.ppy.sh/ss/17225214/e8…
πŸ‘︎ 160
πŸ’¬︎
πŸ‘€︎ u/Wonderer0103
πŸ“…︎ Nov 04 2021
🚨︎ report
WHY ARE THERE TWO TYPES OF SEMAPHORE SIGNALS AND WHY DID IT CHANGE AND HOW DO I TURN IT BACK AAAAAAAHHHHHHH
πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/kyldeking
πŸ“…︎ Nov 09 2021
🚨︎ report
"Semaphore Time Ball Tower" pen and pencil on paper bluethumb.com.au/jefferso…
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/TheDatageddon
πŸ“…︎ Dec 23 2021
🚨︎ report
The first basement floor has a secret room with these markings on the wall. I believe they're in flag semaphore, but they're not quite there. Does anyone want to take a crack at this or have any other cryptology knowledge? reddit.com/gallery/rkd4jy
πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/The_Negotiator_B1
πŸ“…︎ Dec 20 2021
🚨︎ report
with this amount of flags, the characters should learn how to communicate in semaphore reddit.com/gallery/qtt8p0
πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/OkPossibility195
πŸ“…︎ Nov 14 2021
🚨︎ report
Mowgli x Midnite Djong - Semaphore feat. Sambit Chatterjee (2021) youtu.be/-OlzW7HynsA
πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/idkanythang
πŸ“…︎ Dec 12 2021
🚨︎ report
Has anyone ported 40% keyboards' semaphore to QMK?

Edit - Solved, thanks to /u/covah901

I've ordered semaphore PCB and would like to run QMK on them.

https://www.40percent.club/2019/06/semaphore.html

40% keyboards' suggested firmware is TMK which I have no experience with. I have more experience with QMK but have never created config files from scratch on it.

Has anyone created config files that they would like to share, to save me the trouble?

Thanks

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/NotEnoughData
πŸ“…︎ Nov 29 2021
🚨︎ report
Mowgli x Midnite Djong - Semaphore feat. Sambit Chatterjee (2021) youtu.be/-OlzW7HynsA
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/idkanythang
πŸ“…︎ Dec 12 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.