Re: [go-nuts] What does a deadlock mean in golang?

2019-01-30 Thread Michael Jones
fantastic read!

On Wed, Jan 30, 2019 at 12:42 PM Bakul Shah  wrote:

> On Wed, 30 Jan 2019 12:21:46 -0800 Tom Mitchell 
> wrote:
> >
> > On Tue, Jan 29, 2019 at 12:55 AM =E4=BC=8A=E8=97=A4=E5=92=8C=E4=B9=9F
>  > a.ito.dr...@gmail.com> wrote:
> >
> > > I know the general meaning of a deadlock, but I don't know the meaning
> of
> > > a deadlock in golang.
> > >
> >
> > Good question...
> > A classic and now hard to find reference for a deadlock is "Operating
> > System Principles (Prentice-Hall Series in Automatic Computation) by Per
> > Brinch Hansen"
> >
>
> This is the classic paper on Deadlocks:
>
>
> http://www.ccs.neu.edu/home/pjd/cs7600-s10/Tuesday_January_26_01/p67-coffman.pdf
>
> @article{Coffman:1971:SD:356586.356588,
>  author = {Coffman, E. G. and Elphick, M. and Shoshani, A.},
>  title = {System Deadlocks},
>  journal = {ACM Comput. Surv.},
>  issue_date = {June 1971},
>  volume = {3},
>  number = {2},
>  month = jun,
>  year = {1971},
>  issn = {0360-0300},
>  pages = {67--78},
>  numpages = {12},
>  url = {http://doi.acm.org/10.1145/356586.356588},
>  doi = {10.1145/356586.356588},
>  acmid = {356588},
>  publisher = {ACM},
>  address = {New York, NY, USA},
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-30 Thread Bakul Shah
On Wed, 30 Jan 2019 12:21:46 -0800 Tom Mitchell  wrote:
>
> On Tue, Jan 29, 2019 at 12:55 AM =E4=BC=8A=E8=97=A4=E5=92=8C=E4=B9=9F  a.ito.dr...@gmail.com> wrote:
>
> > I know the general meaning of a deadlock, but I don't know the meaning of
> > a deadlock in golang.
> >
>
> Good question...
> A classic and now hard to find reference for a deadlock is "Operating
> System Principles (Prentice-Hall Series in Automatic Computation) by Per
> Brinch Hansen"
>

This is the classic paper on Deadlocks:

http://www.ccs.neu.edu/home/pjd/cs7600-s10/Tuesday_January_26_01/p67-coffman.pdf

@article{Coffman:1971:SD:356586.356588,
 author = {Coffman, E. G. and Elphick, M. and Shoshani, A.},
 title = {System Deadlocks},
 journal = {ACM Comput. Surv.},
 issue_date = {June 1971},
 volume = {3},
 number = {2},
 month = jun,
 year = {1971},
 issn = {0360-0300},
 pages = {67--78},
 numpages = {12},
 url = {http://doi.acm.org/10.1145/356586.356588},
 doi = {10.1145/356586.356588},
 acmid = {356588},
 publisher = {ACM},
 address = {New York, NY, USA},
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-30 Thread Tom Mitchell
On Tue, Jan 29, 2019 at 12:55 AM 伊藤和也  wrote:

> I know the general meaning of a deadlock, but I don't know the meaning of
> a deadlock in golang.
>

Good question...
A classic and now hard to find reference for a deadlock is "Operating
System Principles (Prentice-Hall Series in Automatic Computation) by Per
Brinch Hansen"


> For example, I send 4 values to a buffered channel whose maxmum size is 3
> and a deadlock occurs.
>

Yours is blocking I/O and not a programming error with semaphores,
monitors  and mutual exclusion
of your own design.

Since the internals of Go detect this it seems correct but the run time
detection would not reach out to
other machines in the case of channel I/O abstracted to and on a  far away
resource.  The message
in all no progress cases likely should have a unique error.  If an event
could unblock this then the presence
of an event handler is or is not checked.  Timers... ?

Interesting.




-- 
   T o mM i t c h e l l

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread Ian Lance Taylor
On Tue, Jan 29, 2019 at 12:55 AM 伊藤和也  wrote:
>
> I know the general meaning of a deadlock, but I don't know the meaning of a 
> deadlock in golang. For example, I send 4 values to a buffered channel whose 
> maxmum size is 3 and a deadlock occurs. I think this is just "values are out 
> of bounds" like array.

Sending a value on a buffered channel, where the buffer is full, is
not like an array "index out of bounds" error.  Channels are not
arrays.  If the buffer is full, the channel send will block until some
other goroutine receives a value from the channel.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread Ian Denhardt
Yes, exactly. It's a deadlock in the general sense, but this case is
particularly easy to detect: if all of the goroutines in your program
are blocked on some channel operation, then the runtime's scheduler
notices it has nothing it can do and reports that the system has
deadlocked.

-Ian

Quoting diego patricio (2019-01-29 03:59:13)
>Hi,�  maybe it's because no goroutine read the channel,�  the four
>value cause the deadlock because for write that value there is no space
>in the channel,�  sorry by my English, I'm new in go too...�
>
>El mar., 29 ene. 2019 9:55,  <[1]kazya.ito.dr...@gmail.com>
>escribió:
>
>I know the general meaning of a deadlock, but I don't know the meaning
>of a deadlock in golang. For example, I send 4 values to a buffered
>channel whose maxmum size is 3 and a deadlock occurs. I think this is
>just "values are out of bounds" like array. What does a deaklock mean
>in golang?
> func main() {
>ch1 := make(chan int, 3)
>ch1<- 10
>ch1<- 20
>ch1<- 30
>ch1<- 40
> }
>
> fatal error: all goroutines are asleep - deadlock!
>
>  --
>  You received this message because you are subscribed to the Google
>  Groups "golang-nuts" group.
>  To unsubscribe from this group and stop receiving emails from it,
>  send an email to [2]golang-nuts+unsubscr...@googlegroups.com.
>  For more options, visit [3]https://groups.google.com/d/optout.
>
>--
>You received this message because you are subscribed to the Google
>Groups "golang-nuts" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to [4]golang-nuts+unsubscr...@googlegroups.com.
>For more options, visit [5]https://groups.google.com/d/optout.
>
> Verweise
>
>1. mailto:kazya.ito.dr...@gmail.com
>2. mailto:golang-nuts+unsubscr...@googlegroups.com
>3. https://groups.google.com/d/optout
>4. mailto:golang-nuts+unsubscr...@googlegroups.com
>5. https://groups.google.com/d/optout

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread Ian Davis
It's because the goroutine executing the main function blocks until the last 
channel send completes. But since you don't have another goroutine receiving 
from the channel the program cannot continue and remains in a blocked state. 
This is the cause of the deadlock.

On Tue, 29 Jan 2019, at 8:55 AM, 伊藤和也 wrote:
> I know the general meaning of a deadlock, but I don't know the meaning of a 
> deadlock in golang. For example, I send 4 values to a buffered channel whose 
> maxmum size is 3 and a deadlock occurs. I think this is just "values are out 
> of bounds" like array. What does a deaklock mean in golang?
> func main() {
>ch1 := make(chan int, 3)**
   **ch1<- 10**
   **ch1<- 20**
   **ch1<- 30**
   **ch1<- 40**
**}
> 
> fatal error: all goroutines are asleep - deadlock!
> 


> --
>  You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
>  To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
>  For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread diego patricio
Hi,  maybe it's because no goroutine read the channel,  the four value
cause the deadlock because for write that value there is no space in the
channel,  sorry by my English, I'm new in go too...

El mar., 29 ene. 2019 9:55, 伊藤和也  escribió:

> I know the general meaning of a deadlock, but I don't know the meaning of
> a deadlock in golang. For example, I send 4 values to a buffered channel
> whose maxmum size is 3 and a deadlock occurs. I think this is just "values
> are out of bounds" like array. What does a deaklock mean in golang?
>
> func main() {
>ch1 := make(chan int, 3)
>ch1<- 10
>ch1<- 20
>ch1<- 30
>ch1<- 40
> }
>
>
> fatal error: all goroutines are asleep - deadlock!
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.